Skip to content

Fix clippy warnings #321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/devices/src/virtio/console/port_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
}
Expand Down Expand Up @@ -173,9 +173,7 @@ impl PortOutputLog {

impl PortOutput for PortOutputLog {
fn write_volatile(&mut self, buf: &VolatileSlice) -> Result<usize, io::Error> {
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() {
Expand Down
6 changes: 3 additions & 3 deletions src/devices/src/virtio/fs/linux/passthrough.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down Expand Up @@ -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());
}

Expand Down Expand Up @@ -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());
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libkrun/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/vmm/src/linux/vstate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(());
}
Expand Down
Loading