From a3fb28685fb790e961681dbff341d1a8b80a59b7 Mon Sep 17 00:00:00 2001 From: Costin Lupu Date: Wed, 3 Jan 2024 18:32:15 +0100 Subject: [PATCH] samples/command_executer: Fix warnings generated by Clippy Adding command-executer as a workspace member brings the advantage of including the component for Clippy scanning. Signed-off-by: Costin Lupu --- samples/command_executer/src/command_parser.rs | 6 +----- samples/command_executer/src/lib.rs | 8 ++++---- samples/command_executer/src/protocol_helpers.rs | 4 ++-- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/samples/command_executer/src/command_parser.rs b/samples/command_executer/src/command_parser.rs index 0d321f44..9feaf7c3 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 afa635e5..f2c0bf44 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 39d297c1..2cc171fe 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(()) }