diff --git a/samples/command_executer/src/command_parser.rs b/samples/command_executer/src/command_parser.rs index 0d321f44e..9feaf7c38 100644 --- a/samples/command_executer/src/command_parser.rs +++ b/samples/command_executer/src/command_parser.rs @@ -101,11 +101,7 @@ fn parse_command(args: &ArgMatches) -> Result { } fn parse_no_wait(args: &ArgMatches) -> bool { - if args.is_present("no-wait") { - true - } else { - false - } + args.is_present("no-wait") } fn parse_localfile(args: &ArgMatches) -> Result { diff --git a/samples/command_executer/src/lib.rs b/samples/command_executer/src/lib.rs index afa635e56..f2c0bf44e 100644 --- a/samples/command_executer/src/lib.rs +++ b/samples/command_executer/src/lib.rs @@ -120,7 +120,7 @@ fn run_server(fd: RawFd, no_wait: bool) -> Result<(), String> { let buf = json_output.as_bytes(); let len: u64 = buf.len().try_into().map_err(|err| format!("{:?}", err))?; send_u64(fd, len)?; - send_loop(fd, &buf, len)?; + send_loop(fd, buf, len)?; Ok(()) } @@ -261,7 +261,7 @@ pub fn run(args: RunArgs) -> Result { let buf = args.command.as_bytes(); let len: u64 = buf.len().try_into().map_err(|err| format!("{:?}", err))?; send_u64(socket_fd, len)?; - send_loop(socket_fd, &buf, len)?; + send_loop(socket_fd, buf, len)?; // recv output let mut buf = [0u8; BUF_MAX_LEN]; @@ -304,7 +304,7 @@ pub fn recv_file(args: FileArgs) -> Result<(), String> { let buf = args.remotefile.as_bytes(); let len: u64 = buf.len().try_into().map_err(|err| format!("{:?}", err))?; send_u64(socket_fd, len)?; - send_loop(socket_fd, &buf, len)?; + send_loop(socket_fd, buf, len)?; // Receive filesize let filesize = recv_u64(socket_fd)?; @@ -344,7 +344,7 @@ pub fn send_file(args: FileArgs) -> Result<(), String> { let buf = args.remotefile.as_bytes(); let len: u64 = buf.len().try_into().map_err(|err| format!("{:?}", err))?; send_u64(socket_fd, len)?; - send_loop(socket_fd, &buf, len)?; + send_loop(socket_fd, buf, len)?; let filesize = file .metadata() diff --git a/samples/command_executer/src/protocol_helpers.rs b/samples/command_executer/src/protocol_helpers.rs index 39d297c14..2cc171fec 100644 --- a/samples/command_executer/src/protocol_helpers.rs +++ b/samples/command_executer/src/protocol_helpers.rs @@ -7,7 +7,7 @@ use std::os::unix::io::RawFd; pub fn send_u64(fd: RawFd, val: u64) -> Result<(), String> { let mut buf = [0u8; 9]; LittleEndian::write_u64(&mut buf, val); - send_loop(fd, &mut buf, 9)?; + send_loop(fd, &buf, 9)?; Ok(()) } @@ -21,7 +21,7 @@ pub fn recv_u64(fd: RawFd) -> Result { pub fn send_i32(fd: RawFd, val: i32) -> Result<(), String> { let mut buf = [0u8; 4]; LittleEndian::write_i32(&mut buf, val); - send_loop(fd, &mut buf, 4)?; + send_loop(fd, &buf, 4)?; Ok(()) } diff --git a/vsock_proxy/src/starter.rs b/vsock_proxy/src/starter.rs index 7684425ea..ed78c3264 100644 --- a/vsock_proxy/src/starter.rs +++ b/vsock_proxy/src/starter.rs @@ -48,7 +48,7 @@ pub fn check_allowlist( // Obtain the remote server's IP address. let mut addrs = Proxy::parse_addr(remote_host, only_4, only_6) .map_err(|err| format!("Could not parse remote address: {}", err))?; - let remote_addr = *addrs.get(0).ok_or("No IP address found")?; + let remote_addr = *addrs.first().ok_or("No IP address found")?; for raw_service in services { let addr = raw_service["address"].as_str().ok_or("No address field")?;