From 837e1146ea76e1e9e4f2d1ad3e35a60811152473 Mon Sep 17 00:00:00 2001 From: Eugene Koira Date: Tue, 25 Jun 2024 10:09:18 +0000 Subject: [PATCH] clippy: resolve build errors for Rust 1.79 Resolving clippy errors when building with Rust 1.79: * https://rust-lang.github.io/rust-clippy/master/index.html#/legacy_numeric_constants * https://rust-lang.github.io/rust-clippy/master/index.html#/manual_unwrap_or_default Signed-off-by: Eugene Koira --- samples/command_executer/src/lib.rs | 7 +------ src/common/commands_parser.rs | 4 ++-- src/utils.rs | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/samples/command_executer/src/lib.rs b/samples/command_executer/src/lib.rs index f2c0bf44..664aeddf 100644 --- a/samples/command_executer/src/lib.rs +++ b/samples/command_executer/src/lib.rs @@ -283,12 +283,7 @@ pub fn run(args: RunArgs) -> Result { print!("{}", output.stdout); eprint!("{}", output.stderr); - let rc = match output.rc { - Some(code) => code, - _ => 0, - }; - - Ok(rc) + Ok(output.rc.unwrap_or_default()) } pub fn recv_file(args: FileArgs) -> Result<(), String> { diff --git a/src/common/commands_parser.rs b/src/common/commands_parser.rs index 0da9a7a1..78009196 100644 --- a/src/common/commands_parser.rs +++ b/src/common/commands_parser.rs @@ -403,7 +403,7 @@ fn parse_enclave_cid(args: &ArgMatches) -> NitroCliResult> { )); } - if enclave_cid == u32::max_value() as u64 { + if enclave_cid == u32::MAX as u64 { return Err(new_nitro_cli_failure!( &format!( "CID {} is a well-known CID, not to be used for enclaves", @@ -425,7 +425,7 @@ fn parse_enclave_cid(args: &ArgMatches) -> NitroCliResult> { } // 64-bit CIDs are not yet supported for the vsock device. - if enclave_cid > u32::max_value() as u64 { + if enclave_cid > u32::MAX as u64 { return Err(new_nitro_cli_failure!( &format!( "CID {} is higher than the maximum supported (u32 max) for a vsock device", diff --git a/src/utils.rs b/src/utils.rs index bc368f5c..7fef629d 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -321,7 +321,7 @@ fn vsock_set_connect_timeout(fd: RawFd, millis: i64) -> NitroCliResult<()> { /// limit of enclave memory based on the EIF file size. pub fn ceil_div(lhs: u64, rhs: u64) -> u64 { if rhs == 0 { - return std::u64::MAX; + return u64::MAX; } lhs / rhs