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:
Bo Chen
2023-01-18 12:43:36 -08:00
committed by Bo Chen
parent 1adfb7e9f8
commit c91a8e1324
60 changed files with 457 additions and 583 deletions

View File

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

View File

@@ -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}"),
))
}
}

View File

@@ -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:?}"),
)
})?;

View File

@@ -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:?}"
),
)
})

View File

@@ -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:?}"),
))
})?;

View File

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

View File

@@ -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:?}"),
}
}
}

View File

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

View File

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