Skip to content

Commit 3722a25

Browse files
committed
Fix clippy warnings
Signed-off-by: Tyler Fanelli <[email protected]>
1 parent d8a1bc9 commit 3722a25

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

src/devices/src/virtio/console/port_io.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl PortOutput for PortOutputFd {
118118
VolatileMemoryError::IOError(e) => e,
119119
e => {
120120
log::error!("Unsuported error from write_volatile: {e:?}");
121-
io::Error::new(ErrorKind::Other, e)
121+
io::Error::other(e)
122122
}
123123
})
124124
}
@@ -173,9 +173,7 @@ impl PortOutputLog {
173173

174174
impl PortOutput for PortOutputLog {
175175
fn write_volatile(&mut self, buf: &VolatileSlice) -> Result<usize, io::Error> {
176-
self.buf
177-
.write_volatile(buf)
178-
.map_err(|e| io::Error::new(ErrorKind::Other, e))?;
176+
self.buf.write_volatile(buf).map_err(io::Error::other)?;
179177

180178
let mut start = 0;
181179
for (i, ch) in self.buf.iter().cloned().enumerate() {

src/devices/src/virtio/fs/linux/passthrough.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2030,7 +2030,7 @@ impl FileSystem for PassthroughFs {
20302030
0,
20312031
)
20322032
};
2033-
if ret == libc::MAP_FAILED {
2033+
if std::ptr::eq(ret, libc::MAP_FAILED) {
20342034
return Err(io::Error::last_os_error());
20352035
}
20362036

@@ -2062,7 +2062,7 @@ impl FileSystem for PassthroughFs {
20622062
foffset as libc::off_t,
20632063
)
20642064
};
2065-
if ret == libc::MAP_FAILED {
2065+
if std::ptr::eq(ret, libc::MAP_FAILED) {
20662066
return Err(io::Error::last_os_error());
20672067
}
20682068

@@ -2092,7 +2092,7 @@ impl FileSystem for PassthroughFs {
20922092
0_i64,
20932093
)
20942094
};
2095-
if ret == libc::MAP_FAILED {
2095+
if std::ptr::eq(ret, libc::MAP_FAILED) {
20962096
return Err(io::Error::last_os_error());
20972097
}
20982098
}

src/libkrun/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ fn map_kernel(ctx_id: u32, kernel_path: &PathBuf) -> i32 {
11601160
0_i64,
11611161
)
11621162
};
1163-
if kernel_host_addr == libc::MAP_FAILED {
1163+
if std::ptr::eq(kernel_host_addr, libc::MAP_FAILED) {
11641164
error!("Can't load kernel into process map");
11651165
return -libc::EINVAL;
11661166
}

src/vmm/src/linux/vstate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ impl Vcpu {
828828
// _before_ running this, then there is nothing we can do.
829829
Self::TLS_VCPU_PTR.with(|cell: &VcpuCell| {
830830
if let Some(vcpu_ptr) = cell.get() {
831-
if vcpu_ptr == self as *mut Vcpu {
831+
if std::ptr::eq(vcpu_ptr, self) {
832832
Self::TLS_VCPU_PTR.with(|cell: &VcpuCell| cell.take());
833833
return Ok(());
834834
}

0 commit comments

Comments
 (0)