Skip to content

Commit

Permalink
samples/command_executer: Fix warnings generated by Clippy
Browse files Browse the repository at this point in the history
Signed-off-by: Costin Lupu <[email protected]>
  • Loading branch information
clupuishere committed Jan 3, 2024
1 parent 2686417 commit 5a49a75
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
6 changes: 1 addition & 5 deletions samples/command_executer/src/command_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,7 @@ fn parse_command(args: &ArgMatches) -> Result<String, String> {
}

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<String, String> {
Expand Down
8 changes: 4 additions & 4 deletions samples/command_executer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

Expand Down Expand Up @@ -261,7 +261,7 @@ pub fn run(args: RunArgs) -> Result<i32, String> {
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];
Expand Down Expand Up @@ -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)?;
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions samples/command_executer/src/protocol_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

Expand All @@ -21,7 +21,7 @@ pub fn recv_u64(fd: RawFd) -> Result<u64, String> {
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(())
}

Expand Down

0 comments on commit 5a49a75

Please sign in to comment.