From a64ba04e782dfcca991b93ae47d0844f25db3d60 Mon Sep 17 00:00:00 2001 From: Jinank Jain Date: Wed, 2 Apr 2025 08:03:45 +0000 Subject: [PATCH] pci: Fix clippy warning while comparing raw pointers Use the builtin function instead of using `==` operator. Warning from the beta compiler: error: use `std::ptr::eq` when comparing raw pointers --> pci/src/vfio.rs:1616:24 if host_addr == libc::MAP_FAILED { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::eq(host_addr, libc::MAP_FAILED)` = help: for further information visit = https://rust-lang.github.io/rust-clippy/master/index.html#ptr_eq = note: `-D clippy::ptr-eq` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::ptr_eq)]` Signed-off-by: Jinank Jain --- hypervisor/src/mshv/mod.rs | 2 +- pci/src/vfio.rs | 2 +- pci/src/vfio_user.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hypervisor/src/mshv/mod.rs b/hypervisor/src/mshv/mod.rs index 725dfc347..6684838b6 100644 --- a/hypervisor/src/mshv/mod.rs +++ b/hypervisor/src/mshv/mod.rs @@ -1813,7 +1813,7 @@ impl vm::Vm for MshvVm { MSHV_VP_MMAP_OFFSET_GHCB as i64 * libc::sysconf(libc::_SC_PAGE_SIZE), ) }; - if addr == libc::MAP_FAILED { + if std::ptr::eq(addr, libc::MAP_FAILED) { // No point of continuing, without this mmap VMGEXIT will fail anyway // Return error return Err(vm::HypervisorVmError::MmapToRoot); diff --git a/pci/src/vfio.rs b/pci/src/vfio.rs index bad337f1e..4cf99de63 100644 --- a/pci/src/vfio.rs +++ b/pci/src/vfio.rs @@ -1613,7 +1613,7 @@ impl VfioPciDevice { ) }; - if host_addr == libc::MAP_FAILED { + if std::ptr::eq(host_addr, libc::MAP_FAILED) { error!( "Could not mmap sparse area (offset = 0x{:x}, size = 0x{:x}): {}", area.offset, diff --git a/pci/src/vfio_user.rs b/pci/src/vfio_user.rs index cde2aec08..b0e41a02c 100644 --- a/pci/src/vfio_user.rs +++ b/pci/src/vfio_user.rs @@ -169,7 +169,7 @@ impl VfioUserPciDevice { ) }; - if host_addr == libc::MAP_FAILED { + if std::ptr::eq(host_addr, libc::MAP_FAILED) { error!( "Could not mmap regions, error:{}", std::io::Error::last_os_error()