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 <jinankjain@microsoft.com>
This commit is contained in:
Jinank Jain 2025-04-02 08:03:45 +00:00
parent b686a5bb24
commit a64ba04e78
3 changed files with 3 additions and 3 deletions

View file

@ -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);

View file

@ -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,

View file

@ -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()