diff --git a/src/devices/src/virtio/console/port_io.rs b/src/devices/src/virtio/console/port_io.rs index 1862afcfb..06086b7a0 100644 --- a/src/devices/src/virtio/console/port_io.rs +++ b/src/devices/src/virtio/console/port_io.rs @@ -118,7 +118,7 @@ impl PortOutput for PortOutputFd { VolatileMemoryError::IOError(e) => e, e => { log::error!("Unsuported error from write_volatile: {e:?}"); - io::Error::new(ErrorKind::Other, e) + io::Error::other(e) } }) } @@ -173,9 +173,7 @@ impl PortOutputLog { impl PortOutput for PortOutputLog { fn write_volatile(&mut self, buf: &VolatileSlice) -> Result { - self.buf - .write_volatile(buf) - .map_err(|e| io::Error::new(ErrorKind::Other, e))?; + self.buf.write_volatile(buf).map_err(io::Error::other)?; let mut start = 0; for (i, ch) in self.buf.iter().cloned().enumerate() { diff --git a/src/devices/src/virtio/fs/linux/passthrough.rs b/src/devices/src/virtio/fs/linux/passthrough.rs index 3cace4433..d4832ee15 100644 --- a/src/devices/src/virtio/fs/linux/passthrough.rs +++ b/src/devices/src/virtio/fs/linux/passthrough.rs @@ -2030,7 +2030,7 @@ impl FileSystem for PassthroughFs { 0, ) }; - if ret == libc::MAP_FAILED { + if std::ptr::eq(ret, libc::MAP_FAILED) { return Err(io::Error::last_os_error()); } @@ -2062,7 +2062,7 @@ impl FileSystem for PassthroughFs { foffset as libc::off_t, ) }; - if ret == libc::MAP_FAILED { + if std::ptr::eq(ret, libc::MAP_FAILED) { return Err(io::Error::last_os_error()); } @@ -2092,7 +2092,7 @@ impl FileSystem for PassthroughFs { 0_i64, ) }; - if ret == libc::MAP_FAILED { + if std::ptr::eq(ret, libc::MAP_FAILED) { return Err(io::Error::last_os_error()); } } diff --git a/src/libkrun/src/lib.rs b/src/libkrun/src/lib.rs index 8131fee8c..0a0bce7c6 100644 --- a/src/libkrun/src/lib.rs +++ b/src/libkrun/src/lib.rs @@ -1160,7 +1160,7 @@ fn map_kernel(ctx_id: u32, kernel_path: &PathBuf) -> i32 { 0_i64, ) }; - if kernel_host_addr == libc::MAP_FAILED { + if std::ptr::eq(kernel_host_addr, libc::MAP_FAILED) { error!("Can't load kernel into process map"); return -libc::EINVAL; } diff --git a/src/vmm/src/linux/vstate.rs b/src/vmm/src/linux/vstate.rs index 6deae875e..23388374a 100644 --- a/src/vmm/src/linux/vstate.rs +++ b/src/vmm/src/linux/vstate.rs @@ -828,7 +828,7 @@ impl Vcpu { // _before_ running this, then there is nothing we can do. Self::TLS_VCPU_PTR.with(|cell: &VcpuCell| { if let Some(vcpu_ptr) = cell.get() { - if vcpu_ptr == self as *mut Vcpu { + if std::ptr::eq(vcpu_ptr, self) { Self::TLS_VCPU_PTR.with(|cell: &VcpuCell| cell.take()); return Ok(()); }