aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Courbot <acourbot@chromium.org>2022-01-26 16:46:47 +0900
committerCommit Bot <commit-bot@chromium.org>2022-01-28 02:51:14 +0000
commitc61125c154d8aae204ec4e721e3b84a558e1e988 (patch)
tree9fe267c1a80eefe93d7ffbd11b577e1824b59925
parent145f452cf51b4a695a9662f166e2e37a6bd73d84 (diff)
downloadcrosvm-c61125c154d8aae204ec4e721e3b84a558e1e988.tar.gz
devices: fix compile warnings in tests
Fix a few compilation warnings in our tests: * The PCI device had an unused argument without a leading underscore in the name ; * The virtio queue is dereferencing null pointers, which is UB albeit technically ok in this case (bindgen generates similar tests too [1]). [1] https://github.com/rust-lang/rust-bindgen/issues/1651 BUG=None TEST=cargo test in devices/ does not show these warnings anymore. Change-Id: Id272b5381f80bb72d96839a5a6da8bb0c644502d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3418623 Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dennis Kempin <denniskempin@google.com> Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
-rw-r--r--devices/src/pci/pci_device.rs2
-rw-r--r--devices/src/virtio/queue.rs2
2 files changed, 3 insertions, 1 deletions
diff --git a/devices/src/pci/pci_device.rs b/devices/src/pci/pci_device.rs
index e079a3491..58f7878e5 100644
--- a/devices/src/pci/pci_device.rs
+++ b/devices/src/pci/pci_device.rs
@@ -407,7 +407,7 @@ mod tests {
fn write_bar(&mut self, _addr: u64, _data: &[u8]) {}
- fn allocate_address(&mut self, resources: &mut SystemAllocator) -> Result<PciAddress> {
+ fn allocate_address(&mut self, _resources: &mut SystemAllocator) -> Result<PciAddress> {
Err(Error::PciAllocationFailed)
}
diff --git a/devices/src/virtio/queue.rs b/devices/src/virtio/queue.rs
index c2ddf089c..da92eca88 100644
--- a/devices/src/virtio/queue.rs
+++ b/devices/src/virtio/queue.rs
@@ -677,6 +677,7 @@ mod tests {
);
// Calculating the offset of used_event within Avail structure
+ #[allow(deref_nullptr)]
let used_event_offset: u64 =
unsafe { &(*(::std::ptr::null::<Avail>())).used_event as *const _ as u64 };
let used_event_address = GuestAddress(AVAIL_OFFSET + used_event_offset);
@@ -753,6 +754,7 @@ mod tests {
);
// Calculating the offset of used_event within Avail structure
+ #[allow(deref_nullptr)]
let used_event_offset: u64 =
unsafe { &(*(::std::ptr::null::<Avail>())).used_event as *const _ as u64 };
let used_event_address = GuestAddress(AVAIL_OFFSET + used_event_offset);