diff --git a/Cargo.toml b/Cargo.toml index 26182ebca..1f6351b24 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -173,6 +173,7 @@ suspicious = "deny" assertions_on_result_states = "deny" manual_string_new = "deny" map_unwrap_or = "deny" +redundant_else = "deny" semicolon_if_nothing_returned = "deny" undocumented_unsafe_blocks = "deny" uninlined_format_args = "deny" diff --git a/hypervisor/src/kvm/mod.rs b/hypervisor/src/kvm/mod.rs index 0ecf9a48d..786ab8a82 100644 --- a/hypervisor/src/kvm/mod.rs +++ b/hypervisor/src/kvm/mod.rs @@ -1214,9 +1214,8 @@ impl hypervisor::Hypervisor for KvmHypervisor { // ioctl has been interrupted, we have to retry as // this can't be considered as a regular error. continue; - } else { - return Err(hypervisor::HypervisorError::VmCreate(e.into())); } + return Err(hypervisor::HypervisorError::VmCreate(e.into())); } } break; diff --git a/hypervisor/src/mshv/mod.rs b/hypervisor/src/mshv/mod.rs index 719456720..a7de46080 100644 --- a/hypervisor/src/mshv/mod.rs +++ b/hypervisor/src/mshv/mod.rs @@ -303,9 +303,8 @@ impl hypervisor::Hypervisor for MshvHypervisor { // ioctl has been interrupted, we have to retry as // this can't be considered as a regular error. continue; - } else { - return Err(hypervisor::HypervisorError::VmCreate(e.into())); } + return Err(hypervisor::HypervisorError::VmCreate(e.into())); } } break; diff --git a/pci/src/configuration.rs b/pci/src/configuration.rs index b97c46c0b..4dbd04f12 100644 --- a/pci/src/configuration.rs +++ b/pci/src/configuration.rs @@ -948,12 +948,11 @@ impl PciConfiguration { self.pending_bar_reprogram ); return self.pending_bar_reprogram.drain(..).collect(); - } else { - info!( - "MSE bit is disabled. No BAR reprogramming parameter is returned: {:x?}", - self.pending_bar_reprogram - ); } + info!( + "MSE bit is disabled. No BAR reprogramming parameter is returned: {:x?}", + self.pending_bar_reprogram + ); } Vec::new() diff --git a/pci/src/vfio.rs b/pci/src/vfio.rs index 87adf08d8..bb45e6c00 100644 --- a/pci/src/vfio.rs +++ b/pci/src/vfio.rs @@ -910,16 +910,15 @@ impl VfioCommon { let cap_id = self.vfio_wrapper.read_config_byte(cap_next.into()); if PciCapabilityId::from(cap_id) == PciCapabilityId::MsiX { return Some(cap_next as usize); - } else { - let cap_ptr = self.vfio_wrapper.read_config_byte((cap_next + 1).into()) - & PCI_CONFIG_CAPABILITY_PTR_MASK; + } + let cap_ptr = self.vfio_wrapper.read_config_byte((cap_next + 1).into()) + & PCI_CONFIG_CAPABILITY_PTR_MASK; - // See parse_capabilities below for an explanation. - if cap_ptr != cap_next { - cap_next = cap_ptr; - } else { - break; - } + // See parse_capabilities below for an explanation. + if cap_ptr != cap_next { + cap_next = cap_ptr; + } else { + break; } } diff --git a/rate_limiter/src/group.rs b/rate_limiter/src/group.rs index 54e140161..d0978176b 100644 --- a/rate_limiter/src/group.rs +++ b/rate_limiter/src/group.rs @@ -234,9 +234,8 @@ impl RateLimiterGroup { Err(e) => { if e.kind() == io::ErrorKind::Interrupted { continue; - } else { - return Err(Error::Epoll(e)); } + return Err(Error::Epoll(e)); } }; diff --git a/rate_limiter/src/lib.rs b/rate_limiter/src/lib.rs index cd73253c5..029288ad2 100644 --- a/rate_limiter/src/lib.rs +++ b/rate_limiter/src/lib.rs @@ -168,12 +168,11 @@ impl TokenBucket { self.last_update = Instant::now(); // No need to continue to the refill process, we still have burst budget to consume from. return BucketReduction::Success; - } else { - // We still have burst budget for *some* of the tokens requests. - // The tokens left unfulfilled will be consumed from current `self.budget`. - tokens -= self.one_time_burst; - self.one_time_burst = 0; } + // We still have burst budget for *some* of the tokens requests. + // The tokens left unfulfilled will be consumed from current `self.budget`. + tokens -= self.one_time_burst; + self.one_time_burst = 0; } // Compute time passed since last refill/update. diff --git a/vmm/src/cpu.rs b/vmm/src/cpu.rs index 67cd79bdb..ee5186e6d 100644 --- a/vmm/src/cpu.rs +++ b/vmm/src/cpu.rs @@ -726,17 +726,16 @@ impl VcpuState { loop { if self.vcpu_run_interrupted.load(Ordering::SeqCst) { return Ok(()); - } else { - // This is more effective than thread::yield_now() at - // avoiding a priority inversion with the vCPU thread - thread::sleep(std::time::Duration::from_millis(1)); - count += 1; - if count >= 1000 { - return Err(Error::SignalAcknowledgeTimeout); - } else if count % 10 == 0 { - warn!("vCPU thread did not respond in {count}ms to signal - retrying"); - self.signal_thread(); - } + } + // This is more effective than thread::yield_now() at + // avoiding a priority inversion with the vCPU thread + thread::sleep(std::time::Duration::from_millis(1)); + count += 1; + if count >= 1000 { + return Err(Error::SignalAcknowledgeTimeout); + } else if count % 10 == 0 { + warn!("vCPU thread did not respond in {count}ms to signal - retrying"); + self.signal_thread(); } } } @@ -807,21 +806,20 @@ impl CpuManager { if amx_tile != 0 { return Err(Error::AmxEnable(anyhow!("Guest AMX usage not supported"))); - } else { - let mut mask: usize = 0; - // SAFETY: Syscall with valid parameters. We use a raw mutable pointer to - // the `mask` place in order to ensure that we do not violate Rust's - // aliasing rules. - let result = unsafe { - libc::syscall( - libc::SYS_arch_prctl, - ARCH_GET_XCOMP_GUEST_PERM, - &raw mut mask, - ) - }; - if result != 0 || (mask & XFEATURE_XTILEDATA_MASK) != XFEATURE_XTILEDATA_MASK { - return Err(Error::AmxEnable(anyhow!("Guest AMX usage not supported"))); - } + } + let mut mask: usize = 0; + // SAFETY: Syscall with valid parameters. We use a raw mutable pointer to + // the `mask` place in order to ensure that we do not violate Rust's + // aliasing rules. + let result = unsafe { + libc::syscall( + libc::SYS_arch_prctl, + ARCH_GET_XCOMP_GUEST_PERM, + &raw mut mask, + ) + }; + if result != 0 || (mask & XFEATURE_XTILEDATA_MASK) != XFEATURE_XTILEDATA_MASK { + return Err(Error::AmxEnable(anyhow!("Guest AMX usage not supported"))); } } diff --git a/vmm/src/serial_manager.rs b/vmm/src/serial_manager.rs index 6fa94a0c2..efb8d67e8 100644 --- a/vmm/src/serial_manager.rs +++ b/vmm/src/serial_manager.rs @@ -289,9 +289,8 @@ impl SerialManager { // be considered as a regular error. Instead it is more // appropriate to retry, by calling into epoll_wait(). continue; - } else { - return Err(Error::Epoll(e)); } + return Err(Error::Epoll(e)); } }; diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index f42fe2406..526649c57 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -1743,14 +1743,13 @@ impl Vm { zone.hotplugged_size = Some(hotplugged_size); return Ok(()); - } else { - error!( - "Invalid to ask less ({}) than boot RAM ({}) for \ - this memory zone", - desired_memory, zone.size, - ); - return Err(Error::ResizeZone); } + error!( + "Invalid to ask less ({}) than boot RAM ({}) for \ + this memory zone", + desired_memory, zone.size, + ); + return Err(Error::ResizeZone); } } }