mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
misc: Automatically fix cargo clippy issues added in 1.65 (stable)
The code of the stable branch diverges from the main branch, so we
can't directly backport the corresponding commit to fix the clippy
issues.
See: commit 5e52729453
Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
@@ -454,7 +454,7 @@ impl Block {
|
||||
let disk_size = disk_image.size().map_err(|e| {
|
||||
io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!("Failed getting disk size: {}", e),
|
||||
format!("Failed getting disk size: {e}"),
|
||||
)
|
||||
})?;
|
||||
if disk_size % SECTOR_SIZE != 0 {
|
||||
|
||||
@@ -781,7 +781,7 @@ impl DmaRemapping for IommuMapping {
|
||||
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!("failed to translate GVA addr 0x{:x}", addr),
|
||||
format!("failed to translate GVA addr 0x{addr:x}"),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -809,7 +809,7 @@ impl DmaRemapping for IommuMapping {
|
||||
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!("failed to translate GPA addr 0x{:x}", addr),
|
||||
format!("failed to translate GPA addr 0x{addr:x}"),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -727,10 +727,7 @@ impl Mem {
|
||||
if region_len != region_len / VIRTIO_MEM_ALIGN_SIZE * VIRTIO_MEM_ALIGN_SIZE {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!(
|
||||
"Virtio-mem size is not aligned with {}",
|
||||
VIRTIO_MEM_ALIGN_SIZE
|
||||
),
|
||||
format!("Virtio-mem size is not aligned with {VIRTIO_MEM_ALIGN_SIZE}"),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -756,8 +753,7 @@ impl Mem {
|
||||
io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!(
|
||||
"Failed to resize virtio-mem configuration to {}: {:?}",
|
||||
initial_size, e
|
||||
"Failed to resize virtio-mem configuration to {initial_size}: {e:?}"
|
||||
),
|
||||
)
|
||||
})?;
|
||||
@@ -773,7 +769,7 @@ impl Mem {
|
||||
config.validate().map_err(|e| {
|
||||
io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!("Invalid virtio-mem configuration: {:?}", e),
|
||||
format!("Invalid virtio-mem configuration: {e:?}"),
|
||||
)
|
||||
})?;
|
||||
|
||||
|
||||
@@ -544,9 +544,8 @@ impl<M: GuestAddressSpace + Sync + Send> ExternalDmaMapping for VdpaDmaMapping<M
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!(
|
||||
"failed to convert guest address 0x{:x} into \
|
||||
host user virtual address",
|
||||
gpa
|
||||
"failed to convert guest address 0x{gpa:x} into \
|
||||
host user virtual address"
|
||||
),
|
||||
));
|
||||
};
|
||||
@@ -564,8 +563,7 @@ impl<M: GuestAddressSpace + Sync + Send> ExternalDmaMapping for VdpaDmaMapping<M
|
||||
io::ErrorKind::Other,
|
||||
format!(
|
||||
"failed to map memory for vDPA device, \
|
||||
iova 0x{:x}, gpa 0x{:x}, size 0x{:x}: {:?}",
|
||||
iova, gpa, size, e
|
||||
iova 0x{iova:x}, gpa 0x{gpa:x}, size 0x{size:x}: {e:?}"
|
||||
),
|
||||
)
|
||||
})
|
||||
@@ -582,8 +580,7 @@ impl<M: GuestAddressSpace + Sync + Send> ExternalDmaMapping for VdpaDmaMapping<M
|
||||
io::ErrorKind::Other,
|
||||
format!(
|
||||
"failed to unmap memory for vDPA device, \
|
||||
iova 0x{:x}, size 0x{:x}: {:?}",
|
||||
iova, size, e
|
||||
iova 0x{iova:x}, size 0x{size:x}: {e:?}"
|
||||
),
|
||||
)
|
||||
})
|
||||
|
||||
@@ -216,7 +216,7 @@ impl<S: VhostUserMasterReqHandler> VhostUserEpollHandler<S> {
|
||||
.map_err(|e| {
|
||||
EpollHelperError::IoError(std::io::Error::new(
|
||||
std::io::ErrorKind::Other,
|
||||
format!("failed connecting vhost-user backend {:?}", e),
|
||||
format!("failed connecting vhost-user backend {e:?}"),
|
||||
))
|
||||
})?;
|
||||
|
||||
@@ -237,7 +237,7 @@ impl<S: VhostUserMasterReqHandler> VhostUserEpollHandler<S> {
|
||||
.map_err(|e| {
|
||||
EpollHelperError::IoError(std::io::Error::new(
|
||||
std::io::ErrorKind::Other,
|
||||
format!("failed reconnecting vhost-user backend{:?}", e),
|
||||
format!("failed reconnecting vhost-user backend{e:?}"),
|
||||
))
|
||||
})?;
|
||||
|
||||
|
||||
@@ -853,7 +853,7 @@ mod tests {
|
||||
assert_eq!(pkt.op(), uapi::VSOCK_OP_RESPONSE);
|
||||
conn
|
||||
}
|
||||
other => panic!("invalid ctx state: {:?}", other),
|
||||
other => panic!("invalid ctx state: {other:?}"),
|
||||
};
|
||||
assert_eq!(conn.state, conn_state);
|
||||
Self {
|
||||
@@ -971,7 +971,7 @@ mod tests {
|
||||
// There's no more data in the stream, so `recv_pkt` should yield `VsockError::NoData`.
|
||||
match ctx.conn.recv_pkt(&mut ctx.pkt) {
|
||||
Err(VsockError::NoData) => (),
|
||||
other => panic!("{:?}", other),
|
||||
other => panic!("{other:?}"),
|
||||
}
|
||||
|
||||
// A recv attempt in an invalid state should yield an instant reset packet.
|
||||
|
||||
@@ -234,7 +234,7 @@ mod tests {
|
||||
txbuf.push(tmp.as_slice()).unwrap();
|
||||
match txbuf.push(&[1, 2]) {
|
||||
Err(Error::TxBufFull) => (),
|
||||
other => panic!("Unexpected result: {:?}", other),
|
||||
other => panic!("Unexpected result: {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ mod tests {
|
||||
sink.set_err(io_err);
|
||||
match txbuf.flush_to(&mut sink) {
|
||||
Err(Error::TxBufFlush(ref err)) if err.kind() == ErrorKind::PermissionDenied => (),
|
||||
other => panic!("Unexpected result: {:?}", other),
|
||||
other => panic!("Unexpected result: {other:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -598,7 +598,7 @@ mod tests {
|
||||
.activate(memory.clone(), Arc::new(NoopVirtioInterrupt {}), Vec::new());
|
||||
match bad_activate {
|
||||
Err(ActivateError::BadActivate) => (),
|
||||
other => panic!("{:?}", other),
|
||||
other => panic!("{other:?}"),
|
||||
}
|
||||
|
||||
// Test a correct activation.
|
||||
|
||||
@@ -851,7 +851,7 @@ mod tests {
|
||||
None,
|
||||
)
|
||||
.unwrap();
|
||||
let uds_path = format!("test_vsock_{}.sock", name);
|
||||
let uds_path = format!("test_vsock_{name}.sock");
|
||||
let muxer = VsockMuxer::new(PEER_CID, uds_path).unwrap();
|
||||
|
||||
Self {
|
||||
@@ -931,7 +931,7 @@ mod tests {
|
||||
let (local_lsn_count, _) = self.count_epoll_listeners();
|
||||
assert_eq!(local_lsn_count, init_local_lsn_count + 1);
|
||||
|
||||
let buf = format!("CONNECT {}\n", peer_port);
|
||||
let buf = format!("CONNECT {peer_port}\n");
|
||||
stream.write_all(buf.as_bytes()).unwrap();
|
||||
// The muxer would now get notified that data is available for reading from the locally
|
||||
// initiated connection.
|
||||
@@ -965,7 +965,7 @@ mod tests {
|
||||
|
||||
let mut buf = vec![0u8; 32];
|
||||
let len = stream.read(&mut buf[..]).unwrap();
|
||||
assert_eq!(&buf[..len], format!("OK {}\n", local_port).as_bytes());
|
||||
assert_eq!(&buf[..len], format!("OK {local_port}\n").as_bytes());
|
||||
|
||||
(stream, local_port)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user