mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
misc: clippy: add if_not_else
This removes cognitive load when reading if statements. All changes were applied by clippy via `--fix`. Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de> On-behalf-of: SAP philipp.schuster@sap.com
This commit is contained in:
committed by
Rob Bradford
parent
a0b72dce22
commit
0a07c96d17
@@ -180,11 +180,11 @@ impl PciBus {
|
||||
|
||||
pub fn get_device_id(&mut self, id: usize) -> Result<()> {
|
||||
if id < NUM_DEVICE_IDS {
|
||||
if !self.device_ids[id] {
|
||||
if self.device_ids[id] {
|
||||
Err(PciRootError::AlreadyInUsePciDeviceSlot(id))
|
||||
} else {
|
||||
self.device_ids[id] = true;
|
||||
Ok(())
|
||||
} else {
|
||||
Err(PciRootError::AlreadyInUsePciDeviceSlot(id))
|
||||
}
|
||||
} else {
|
||||
Err(PciRootError::InvalidPciDeviceSlot(id))
|
||||
|
||||
@@ -646,20 +646,20 @@ impl VfioCommon {
|
||||
flags = self.vfio_wrapper.read_config_dword(bar_offset);
|
||||
|
||||
// Is this an IO BAR?
|
||||
let io_bar = if bar_id != VFIO_PCI_ROM_REGION_INDEX {
|
||||
matches!(flags & PCI_CONFIG_IO_BAR, PCI_CONFIG_IO_BAR)
|
||||
} else {
|
||||
let io_bar = if bar_id == VFIO_PCI_ROM_REGION_INDEX {
|
||||
false
|
||||
} else {
|
||||
matches!(flags & PCI_CONFIG_IO_BAR, PCI_CONFIG_IO_BAR)
|
||||
};
|
||||
|
||||
// Is this a 64-bit BAR?
|
||||
let is_64bit_bar = if bar_id != VFIO_PCI_ROM_REGION_INDEX {
|
||||
let is_64bit_bar = if bar_id == VFIO_PCI_ROM_REGION_INDEX {
|
||||
false
|
||||
} else {
|
||||
matches!(
|
||||
flags & PCI_CONFIG_MEMORY_BAR_64BIT,
|
||||
PCI_CONFIG_MEMORY_BAR_64BIT
|
||||
)
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
||||
if matches!(
|
||||
@@ -915,11 +915,10 @@ impl VfioCommon {
|
||||
& PCI_CONFIG_CAPABILITY_PTR_MASK;
|
||||
|
||||
// See parse_capabilities below for an explanation.
|
||||
if cap_ptr != cap_next {
|
||||
cap_next = cap_ptr;
|
||||
} else {
|
||||
if cap_ptr == cap_next {
|
||||
break;
|
||||
}
|
||||
cap_next = cap_ptr;
|
||||
}
|
||||
|
||||
None
|
||||
|
||||
Reference in New Issue
Block a user