Skip to content

Commit

Permalink
Fix clippy nits from latest stable rust
Browse files Browse the repository at this point in the history
  • Loading branch information
pfmooney committed Jun 8, 2023
1 parent 96ba33d commit 3d142b1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
46 changes: 24 additions & 22 deletions lib/propolis-client/src/instance_spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,7 @@ mod test {
memory_mb: 8192,
chipset: Chipset::I440Fx { enable_pcie: false },
};
let b2 = b1.clone();
assert!(b1.can_migrate_from_element(&b2).is_ok());
assert!(b1.can_migrate_from_element(&b1).is_ok());
}

#[test]
Expand All @@ -341,22 +340,20 @@ mod test {
chipset: Chipset::I440Fx { enable_pcie: true },
};

let mut b2 = b1.clone();
b2.cpus = 8;
let b2 = Board { cpus: 8, ..b1 };
assert!(matches!(
b1.can_migrate_from_element(&b2),
Err(ElementCompatibilityError::CpuCount(4, 8))
));
b2.cpus = b1.cpus;

b2.memory_mb = b1.memory_mb * 2;
let b2 = Board { memory_mb: b1.memory_mb * 2, ..b1 };
assert!(matches!(
b1.can_migrate_from_element(&b2),
Err(ElementCompatibilityError::MemorySize(4096, 8192))
));
b2.memory_mb = b1.memory_mb;

b2.chipset = Chipset::I440Fx { enable_pcie: false };
let b2 =
Board { chipset: Chipset::I440Fx { enable_pcie: false }, ..b1 };
assert!(matches!(
b1.can_migrate_from_element(&b2),
Err(ElementCompatibilityError::PcieEnablement(true, false))
Expand All @@ -370,8 +367,7 @@ mod test {
backend_name: "storage_backend".to_string(),
pci_path: PciPath::new(0, 5, 0).unwrap(),
};
let d2 = d1.clone();
assert!(d1.can_migrate_from_element(&d2).is_ok());
assert!(d1.can_migrate_from_element(&d1).is_ok());
}

#[test]
Expand All @@ -382,25 +378,28 @@ mod test {
pci_path: PciPath::new(0, 5, 0).unwrap(),
};

let mut d2 = d1.clone();
d2.kind = StorageDeviceKind::Nvme;
let d2 = StorageDevice { kind: StorageDeviceKind::Nvme, ..d1.clone() };
assert!(matches!(
d1.can_migrate_from_element(&d2),
Err(ElementCompatibilityError::StorageDeviceKind(
StorageDeviceKind::Virtio,
StorageDeviceKind::Nvme
))
));
d2.kind = d1.kind;

d2.backend_name = "other_storage_backend".to_string();
let d2 = StorageDevice {
backend_name: "other_storage_backend".to_string(),
..d1
};
assert!(matches!(
d1.can_migrate_from_element(&d2),
Err(ElementCompatibilityError::StorageDeviceBackend(_, _))
));
d2.backend_name = d1.backend_name.clone();

d2.pci_path = PciPath::new(0, 6, 0).unwrap();
let d2 = StorageDevice {
pci_path: PciPath::new(0, 6, 0).unwrap(),
..d1.clone()
};
assert!(matches!(
d1.can_migrate_from_element(&d2),
Err(ElementCompatibilityError::PciPath(_, _))
Expand All @@ -413,8 +412,7 @@ mod test {
backend_name: "net_backend".to_string(),
pci_path: PciPath::new(0, 7, 0).unwrap(),
};
let n2 = n1.clone();
assert!(n1.can_migrate_from_element(&n2).is_ok());
assert!(n1.can_migrate_from_element(&n1).is_ok());
}

#[test]
Expand All @@ -423,16 +421,20 @@ mod test {
backend_name: "net_backend".to_string(),
pci_path: PciPath::new(0, 7, 0).unwrap(),
};
let mut n2 = n1.clone();

n2.backend_name = "other_net_backend".to_string();
let n2 = NetworkDevice {
backend_name: "other_net_backend".to_string(),
..n1
};
assert!(matches!(
n1.can_migrate_from_element(&n2),
Err(ElementCompatibilityError::NetworkDeviceBackend(_, _))
));
n2.backend_name = n1.backend_name.clone();

n2.pci_path = PciPath::new(0, 8, 1).unwrap();
let n2 = NetworkDevice {
pci_path: PciPath::new(0, 8, 1).unwrap(),
..n1.clone()
};
assert!(matches!(
n1.can_migrate_from_element(&n2),
Err(ElementCompatibilityError::PciPath(_, _))
Expand Down
3 changes: 1 addition & 2 deletions lib/propolis/src/hw/nvme/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1039,8 +1039,7 @@ impl Entity for PciNvme {
let ctrl = self.state.lock().unwrap();
assert!(ctrl.paused);

let block_paused = self.notifier.paused();
Box::pin(async move { block_paused.await })
Box::pin(self.notifier.paused())
}

fn migrate(&self) -> Migrator {
Expand Down
3 changes: 1 addition & 2 deletions lib/propolis/src/hw/virtio/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,7 @@ impl Entity for PciVirtioBlock {
self.notifier.resume();
}
fn paused(&self) -> BoxFuture<'static, ()> {
let block_paused = self.notifier.paused();
Box::pin(async move { block_paused.await })
Box::pin(self.notifier.paused())
}
fn migrate(&self) -> Migrator {
Migrator::Multi(self)
Expand Down
2 changes: 1 addition & 1 deletion lib/propolis/src/vmm/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pub fn write_many<T: Sized>(
version: u16,
data: &mut [T],
) -> Result<(), VmmDataError> {
let write_len = (std::mem::size_of::<T>() * data.len()) as u32;
let write_len = std::mem::size_of_val(data) as u32;
let mut xfer = vm_data_xfer {
vdx_vcpuid: vcpuid,
vdx_class: class,
Expand Down

0 comments on commit 3d142b1

Please sign in to comment.