From 8de24b5f08edcaa74e463e97ab96175f7cb293f6 Mon Sep 17 00:00:00 2001 From: Oliver Anderson Date: Tue, 9 Dec 2025 14:41:14 +0100 Subject: [PATCH] vmm: Fix clippy lints This PR fixes some clippy lints in the vmm crate. Signed-off-by: Oliver Anderson On-behalf-of: SAP oliver.anderson@sap.com --- vmm/src/lib.rs | 35 ++++++++++++++++------------------- vmm/src/memory_manager.rs | 6 ++++-- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/vmm/src/lib.rs b/vmm/src/lib.rs index 0298efc06..f34585a68 100644 --- a/vmm/src/lib.rs +++ b/vmm/src/lib.rs @@ -1615,26 +1615,23 @@ impl RequestHandler for Vmm { fn vm_create(&mut self, config: Box) -> result::Result<(), VmError> { // We only store the passed VM config. // The VM will be created when being asked to boot it. - if self.vm_config.is_none() { - self.vm_config = Some(Arc::new(Mutex::new(*config))); - self.console_info = - Some(pre_create_console_devices(self).map_err(VmError::CreateConsoleDevices)?); - - if self - .vm_config - .as_ref() - .unwrap() - .lock() - .unwrap() - .landlock_enable - { - apply_landlock(self.vm_config.as_ref().unwrap().as_ref()) - .map_err(VmError::ApplyLandlock)?; - } - Ok(()) - } else { - Err(VmError::VmAlreadyCreated) + if self.vm_config.is_some() { + return Err(VmError::VmAlreadyCreated); } + + self.vm_config = Some(Arc::new(Mutex::new(*config))); + self.console_info = + Some(pre_create_console_devices(self).map_err(VmError::CreateConsoleDevices)?); + + if self + .vm_config + .as_ref() + .is_some_and(|config| config.lock().unwrap().landlock_enable) + { + apply_landlock(self.vm_config.as_ref().unwrap().as_ref()) + .map_err(VmError::ApplyLandlock)?; + } + Ok(()) } fn vm_boot(&mut self) -> result::Result<(), VmError> { diff --git a/vmm/src/memory_manager.rs b/vmm/src/memory_manager.rs index 1954c1711..8b0cdff6c 100644 --- a/vmm/src/memory_manager.rs +++ b/vmm/src/memory_manager.rs @@ -408,8 +408,10 @@ fn memory_zone_get_align_size(zone: &MemoryZoneConfig) -> Result { } // The `hugepages` is enabled and the `hugepage_size` is specified, just use it directly. - if zone.hugepages && zone.hugepage_size.is_some() { - return Ok(zone.hugepage_size.unwrap()); + if let Some(hugepage_size) = zone.hugepage_size + && zone.hugepages + { + return Ok(hugepage_size); } // There are two scenarios here: