misc: Automatically fix cargo clippy issues added in 1.65 (stable)

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford
2022-12-14 11:41:15 +00:00
parent 8b59316718
commit 5e52729453
57 changed files with 448 additions and 574 deletions

View File

@@ -456,7 +456,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

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

@@ -729,10 +729,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}"),
));
}
@@ -763,8 +760,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:?}"
),
)
})?;
@@ -780,7 +776,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

@@ -548,9 +548,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"
),
));
};
@@ -568,8 +567,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:?}"
),
)
})
@@ -586,8 +584,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

@@ -852,7 +852,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 {
@@ -932,7 +932,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.
@@ -966,7 +966,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)
}