Skip to content

Commit

Permalink
Fix warnings generated by Rust 1.75
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 08dbc6f commit a3a624d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 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
2 changes: 1 addition & 1 deletion vsock_proxy/src/starter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")?;
Expand Down

0 comments on commit a3a624d

Please sign in to comment.