From f122398262fb5e6ebf0e478401822b891ae60292 Mon Sep 17 00:00:00 2001 From: Bo Chen Date: Wed, 17 Sep 2025 00:01:47 +0000 Subject: [PATCH] misc: Fix beta clippy issues Fixed with 'cargo clippy --fix' mostly. Signed-off-by: Bo Chen --- src/main.rs | 10 ++++------ test_infra/src/lib.rs | 8 ++------ vm-migration/src/protocol.rs | 18 ++++-------------- 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/src/main.rs b/src/main.rs index 971d74314..92a4b085d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1094,8 +1094,7 @@ mod unit_tests { #[test] fn test_valid_vm_config_memory() { - vec![ - ( + [( vec!["cloud-hypervisor", "--kernel", "/path/to/kernel", "--memory", "size=1073741824"], r#"{ "payload": {"kernel": "/path/to/kernel"}, @@ -1150,8 +1149,7 @@ mod unit_tests { "memory": {"size": 1073741824, "hotplug_method": "VirtioMem", "hotplug_size": 1073741824} }"#, true, - ), - ] + )] .iter() .for_each(|(cli, openapi, equal)| { compare_vm_config_cli_vs_json(cli, openapi, *equal); @@ -1302,7 +1300,7 @@ mod unit_tests { #[test] fn test_valid_vm_config_net() { - vec![ + [ // This test is expected to fail because the default MAC address is // randomly generated. There's no way we can have twice the same // default value. @@ -1780,7 +1778,7 @@ mod unit_tests { #[test] #[cfg(target_arch = "x86_64")] fn test_valid_vm_config_devices() { - vec![ + [ ( vec![ "cloud-hypervisor", diff --git a/test_infra/src/lib.rs b/test_infra/src/lib.rs index 7dceaecce..8b260a0a6 100644 --- a/test_infra/src/lib.rs +++ b/test_infra/src/lib.rs @@ -1229,18 +1229,14 @@ impl Guest { } } +#[derive(Default)] pub enum VerbosityLevel { + #[default] Warn, Info, Debug, } -impl Default for VerbosityLevel { - fn default() -> Self { - Self::Warn - } -} - impl Display for VerbosityLevel { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use VerbosityLevel::*; diff --git a/vm-migration/src/protocol.rs b/vm-migration/src/protocol.rs index 094a8c1a3..2ed782ae3 100644 --- a/vm-migration/src/protocol.rs +++ b/vm-migration/src/protocol.rs @@ -50,8 +50,9 @@ use crate::MigratableError; // The source can at any time send an "abandon request" to cancel #[repr(u16)] -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Default)] pub enum Command { + #[default] Invalid, Start, Config, @@ -62,12 +63,6 @@ pub enum Command { MemoryFd, } -impl Default for Command { - fn default() -> Self { - Self::Invalid - } -} - #[repr(C)] #[derive(Default, Copy, Clone)] pub struct Request { @@ -139,19 +134,14 @@ impl Request { } #[repr(u16)] -#[derive(Copy, Clone, PartialEq, Eq)] +#[derive(Copy, Clone, PartialEq, Eq, Default)] pub enum Status { + #[default] Invalid, Ok, Error, } -impl Default for Status { - fn default() -> Self { - Self::Invalid - } -} - #[repr(C)] #[derive(Default, Copy, Clone)] pub struct Response {