From c57df607adc80766d6d9afe4cf061b359fd77086 Mon Sep 17 00:00:00 2001 From: Beraldo Leal Date: Tue, 31 Oct 2023 15:51:03 -0400 Subject: [PATCH 1/2] libs: fixes comparison to empty slice Make check gives us an "error: comparison to empty slice". Fixes #8343 Signed-off-by: Beraldo Leal --- src/libs/kata-types/src/config/shared_mount.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libs/kata-types/src/config/shared_mount.rs b/src/libs/kata-types/src/config/shared_mount.rs index 2370ba81aa..3dd2d7f419 100644 --- a/src/libs/kata-types/src/config/shared_mount.rs +++ b/src/libs/kata-types/src/config/shared_mount.rs @@ -36,19 +36,19 @@ pub struct SharedMount { impl SharedMount { pub fn validate(&self) -> Result<()> { - if self.name == "" { + if self.name.is_empty() { return Err(eother!("shared_mount: field 'name' couldn't be empty.")); } - if self.src_ctr == "" { + if self.src_ctr.is_empty() { return Err(eother!("shared_mount: field 'src_ctr' couldn't be empty.")); } - if self.dst_ctr == "" { + if self.dst_ctr.is_empty() { return Err(eother!("shared_mount: field 'dst_ctr' couldn't be empty.")); } - if self.src_path == "" { + if self.src_path.is_empty() { return Err(eother!("shared_mount: field 'src_path' couldn't be empty.")); } - if self.dst_path == "" { + if self.dst_path.is_empty() { return Err(eother!("shared_mount: field 'dst_path' couldn't be empty.")); } From afec54799e04b3bd848450d58a31e3eba64d8c9e Mon Sep 17 00:00:00 2001 From: Beraldo Leal Date: Tue, 31 Oct 2023 15:55:32 -0400 Subject: [PATCH 2/2] libs: fixes dereferenced reference make check is giving us the following error: error: this expression creates a reference which is immediately dereferenced by the compiler. Fixes #8344 Signed-off-by: Beraldo Leal --- src/libs/kata-sys-util/src/protection.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/kata-sys-util/src/protection.rs b/src/libs/kata-sys-util/src/protection.rs index aecb5837d4..51352a9d45 100644 --- a/src/libs/kata-sys-util/src/protection.rs +++ b/src/libs/kata-sys-util/src/protection.rs @@ -152,7 +152,7 @@ pub fn arch_guest_protection( let major_version_str = major_version_str.trim_start_matches(HEX_PREFIX); - let major_version = u32::from_str_radix(&major_version_str, HEX_BASE) + let major_version = u32::from_str_radix(major_version_str, HEX_BASE) .map_err(|e| ProtectionError::FileInvalid(major_file, anyhow!(e)))?; let minor_version_str = std::fs::read_to_string(minor_file.clone()).map_err(|e| { @@ -161,7 +161,7 @@ pub fn arch_guest_protection( let minor_version_str = minor_version_str.trim_start_matches(HEX_PREFIX); - let minor_version = u32::from_str_radix(&minor_version_str, HEX_BASE) + let minor_version = u32::from_str_radix(minor_version_str, HEX_BASE) .map_err(|e| ProtectionError::FileInvalid(minor_file, anyhow!(e)))?; let details = TDXDetails {