diff --git a/crates/vhost/src/vhost_user/connection.rs b/crates/vhost/src/vhost_user/connection.rs index 96cc143..0ac6c40 100644 --- a/crates/vhost/src/vhost_user/connection.rs +++ b/crates/vhost/src/vhost_user/connection.rs @@ -637,7 +637,7 @@ mod tests { #[test] fn create_listener() { let path = temp_path(); - let listener = Listener::new(&path, true).unwrap(); + let listener = Listener::new(path, true).unwrap(); assert!(listener.as_raw_fd() > 0); } @@ -654,7 +654,7 @@ mod tests { #[test] fn accept_connection() { let path = temp_path(); - let listener = Listener::new(&path, true).unwrap(); + let listener = Listener::new(path, true).unwrap(); listener.set_nonblocking(true).unwrap(); // accept on a fd without incoming connection diff --git a/crates/vhost/src/vhost_user/master.rs b/crates/vhost/src/vhost_user/master.rs index fd7e5a1..4ca821d 100644 --- a/crates/vhost/src/vhost_user/master.rs +++ b/crates/vhost/src/vhost_user/master.rs @@ -827,7 +827,7 @@ mod tests { #[test] fn test_features() { let path = temp_path(); - let (master, mut peer) = create_pair(&path); + let (master, mut peer) = create_pair(path); master.set_owner().unwrap(); let (hdr, rfds) = peer.recv_header().unwrap(); @@ -862,7 +862,7 @@ mod tests { #[test] fn test_protocol_features() { let path = temp_path(); - let (mut master, mut peer) = create_pair(&path); + let (mut master, mut peer) = create_pair(path); master.set_owner().unwrap(); let (hdr, rfds) = peer.recv_header().unwrap(); @@ -913,7 +913,7 @@ mod tests { #[test] fn test_master_set_config_negative() { let path = temp_path(); - let (mut master, _peer) = create_pair(&path); + let (mut master, _peer) = create_pair(path); let buf = vec![0x0; MAX_MSG_SIZE + 1]; master @@ -958,7 +958,7 @@ mod tests { fn create_pair2() -> (Master, Endpoint) { let path = temp_path(); - let (master, peer) = create_pair(&path); + let (master, peer) = create_pair(path); { let mut node = master.node(); diff --git a/crates/vhost/src/vhost_user/master_req_handler.rs b/crates/vhost/src/vhost_user/master_req_handler.rs index 0ecda4e..9873b5b 100644 --- a/crates/vhost/src/vhost_user/master_req_handler.rs +++ b/crates/vhost/src/vhost_user/master_req_handler.rs @@ -336,7 +336,7 @@ impl MasterReqHandler { let def_err = libc::EINVAL; let val = match res { Ok(n) => *n, - Err(e) => match &*e { + Err(e) => match e { Error::ReqHandlerError(ioerr) => match ioerr.raw_os_error() { Some(rawerr) => -rawerr as u64, None => -def_err as u64, diff --git a/crates/vhost/src/vhost_user/message.rs b/crates/vhost/src/vhost_user/message.rs index bda5671..35e1e30 100644 --- a/crates/vhost/src/vhost_user/message.rs +++ b/crates/vhost/src/vhost_user/message.rs @@ -624,7 +624,7 @@ impl VhostUserVringAddr { } /// Create a new instance from `VringConfigData`. - #[cfg_attr(feature = "cargo-clippy", allow(clippy::identity_conversion))] + #[cfg_attr(feature = "cargo-clippy", allow(clippy::useless_conversion))] pub fn from_config_data(index: u32, config_data: &VringConfigData) -> Self { let log_addr = config_data.log_addr.unwrap_or(0); VhostUserVringAddr { diff --git a/crates/vhost/src/vhost_user/mod.rs b/crates/vhost/src/vhost_user/mod.rs index 54fa0e9..936e1bb 100644 --- a/crates/vhost/src/vhost_user/mod.rs +++ b/crates/vhost/src/vhost_user/mod.rs @@ -267,7 +267,7 @@ mod tests { fn test_set_owner() { let slave_be = Arc::new(Mutex::new(DummySlaveReqHandler::new())); let path = temp_path(); - let (master, mut slave) = create_slave(&path, slave_be.clone()); + let (master, mut slave) = create_slave(path, slave_be.clone()); assert!(!slave_be.lock().unwrap().owned); master.set_owner().unwrap(); @@ -284,7 +284,7 @@ mod tests { let sbar = mbar.clone(); let path = temp_path(); let slave_be = Arc::new(Mutex::new(DummySlaveReqHandler::new())); - let (mut master, mut slave) = create_slave(&path, slave_be.clone()); + let (mut master, mut slave) = create_slave(path, slave_be.clone()); thread::spawn(move || { slave.handle_request().unwrap(); @@ -328,7 +328,7 @@ mod tests { let sbar = mbar.clone(); let path = temp_path(); let slave_be = Arc::new(Mutex::new(DummySlaveReqHandler::new())); - let (mut master, mut slave) = create_slave(&path, slave_be.clone()); + let (mut master, mut slave) = create_slave(path, slave_be.clone()); thread::spawn(move || { // set_own() diff --git a/crates/vhost/src/vhost_user/slave_req_handler.rs b/crates/vhost/src/vhost_user/slave_req_handler.rs index 68af103..ffde25c 100644 --- a/crates/vhost/src/vhost_user/slave_req_handler.rs +++ b/crates/vhost/src/vhost_user/slave_req_handler.rs @@ -611,11 +611,7 @@ impl SlaveReqHandler { if size - mem::size_of::() != msg.size as usize { return Err(Error::InvalidMessage); } - let flags: VhostUserConfigFlags; - match VhostUserConfigFlags::from_bits(msg.flags) { - Some(val) => flags = val, - None => return Err(Error::InvalidMessage), - } + let flags = VhostUserConfigFlags::from_bits(msg.flags).ok_or(Error::InvalidMessage)?; self.backend .set_config(msg.offset, &buf[mem::size_of::()..], flags)