From aa850b5c3d9e051fc93037d5d3c133f34de0529f Mon Sep 17 00:00:00 2001 From: Bo Chen Date: Fri, 30 Jun 2023 13:49:16 -0700 Subject: [PATCH] misc: Address clippy beta issues Signed-off-by: Bo Chen --- tpm/src/emulator.rs | 6 +----- vhdx/src/vhdx_metadata.rs | 6 +----- virtio-devices/src/vhost_user/fs.rs | 2 +- vm-device/src/bus.rs | 3 +-- vmm/src/cpu.rs | 2 +- vmm/src/memory_manager.rs | 2 +- vmm/src/vm.rs | 2 +- 7 files changed, 7 insertions(+), 16 deletions(-) diff --git a/tpm/src/emulator.rs b/tpm/src/emulator.rs index 86422de9e..33d4a4a62 100644 --- a/tpm/src/emulator.rs +++ b/tpm/src/emulator.rs @@ -309,11 +309,7 @@ impl Emulator { } self.established_flag_cached = true; - if est.resp.bit != 0 { - self.established_flag = false; - } else { - self.established_flag = true; - } + self.established_flag = est.resp.bit == 0; self.established_flag } diff --git a/vhdx/src/vhdx_metadata.rs b/vhdx/src/vhdx_metadata.rs index 6a5602dbc..20a56add7 100644 --- a/vhdx/src/vhdx_metadata.rs +++ b/vhdx/src/vhdx_metadata.rs @@ -145,11 +145,7 @@ impl DiskSpec { let bits = f .read_u32::() .map_err(VhdxMetadataError::ReadMetadata)?; - if bits & BLOCK_HAS_PARENT != 0 { - disk_spec.has_parent = true; - } else { - disk_spec.has_parent = false; - } + disk_spec.has_parent = bits & BLOCK_HAS_PARENT != 0; metadata_presence |= METADATA_FILE_PARAMETER_PRESENT; } else if metadata_entry.item_id diff --git a/virtio-devices/src/vhost_user/fs.rs b/virtio-devices/src/vhost_user/fs.rs index 58ef70dc9..517a54913 100644 --- a/virtio-devices/src/vhost_user/fs.rs +++ b/virtio-devices/src/vhost_user/fs.rs @@ -605,7 +605,7 @@ impl VirtioDevice for Fs { &mut self, shm_regions: VirtioSharedMemoryList, ) -> std::result::Result<(), crate::Error> { - if let Some(mut cache) = self.cache.as_mut() { + if let Some(cache) = self.cache.as_mut() { cache.0 = shm_regions; Ok(()) } else { diff --git a/vm-device/src/bus.rs b/vm-device/src/bus.rs index 6e581c9a9..bf377154d 100644 --- a/vm-device/src/bus.rs +++ b/vm-device/src/bus.rs @@ -110,8 +110,7 @@ impl Bus { let devices = self.devices.read().unwrap(); let (range, dev) = devices .range(..=BusRange { base: addr, len: 1 }) - .rev() - .next()?; + .next_back()?; dev.upgrade().map(|d| (*range, d.clone())) } diff --git a/vmm/src/cpu.rs b/vmm/src/cpu.rs index 5a7ef2788..d334a56d5 100644 --- a/vmm/src/cpu.rs +++ b/vmm/src/cpu.rs @@ -1131,7 +1131,7 @@ impl CpuManager { fn remove_vcpu(&mut self, cpu_id: u8) -> Result<()> { info!("Removing vCPU: cpu_id = {}", cpu_id); - let mut state = &mut self.vcpu_states[usize::from(cpu_id)]; + let state = &mut self.vcpu_states[usize::from(cpu_id)]; state.kill.store(true, Ordering::SeqCst); state.signal_thread(); state.join_thread()?; diff --git a/vmm/src/memory_manager.rs b/vmm/src/memory_manager.rs index fbb08d7c1..7a164faed 100644 --- a/vmm/src/memory_manager.rs +++ b/vmm/src/memory_manager.rs @@ -1591,7 +1591,7 @@ impl MemoryManager { .ok_or(Error::MemoryRangeAllocation)?; // Update the slot so that it can be queried via the I/O port - let mut slot = &mut self.hotplug_slots[self.next_hotplug_slot]; + let slot = &mut self.hotplug_slots[self.next_hotplug_slot]; slot.active = true; slot.inserting = true; slot.base = region.start_addr().0; diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index 683946f5f..609f6d0ca 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -1258,7 +1258,7 @@ impl Vm { .resize(desired_memory) .map_err(Error::MemoryManager)?; - let mut memory_config = &mut self.config.lock().unwrap().memory; + let memory_config = &mut self.config.lock().unwrap().memory; if let Some(new_region) = &new_region { self.device_manager