From e36857d2b480a1519c6da8be27335e180e5192ff Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Tue, 8 Jul 2025 11:22:28 +0300 Subject: [PATCH] can: run clippy --fix Signed-off-by: Manos Pitsidianakis --- vhost-device-can/src/backend.rs | 9 +++------ vhost-device-can/src/can.rs | 16 ++++++++-------- vhost-device-can/src/main.rs | 2 +- vhost-device-can/src/vhu_can.rs | 8 ++++---- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/vhost-device-can/src/backend.rs b/vhost-device-can/src/backend.rs index c618200..42ce20c 100644 --- a/vhost-device-can/src/backend.rs +++ b/vhost-device-can/src/backend.rs @@ -112,7 +112,7 @@ pub(crate) fn start_backend_server(socket: PathBuf, can_devs: String) -> Result< // Wait for read thread to exit match read_handle.join() { Ok(_) => info!("The read thread returned successfully"), - Err(e) => warn!("The read thread returned the error: {:?}", e), + Err(e) => warn!("The read thread returned the error: {e:?}"), } } } @@ -128,12 +128,9 @@ pub fn start_backend(config: VuCanConfig) -> Result<()> { .map(|(a, b)| (a, b.to_string())) .enumerate() { - println!( - "thread_id: {}, socket: {:?}, can_devs: {:?}", - thread_id, socket, can_devs, - ); + println!("thread_id: {thread_id}, socket: {socket:?}, can_devs: {can_devs:?}",); - let name = format!("vhu-can-{}", can_devs); + let name = format!("vhu-can-{can_devs}"); let sender = senders.clone(); let handle = thread::Builder::new() .name(name.clone()) diff --git a/vhost-device-can/src/can.rs b/vhost-device-can/src/can.rs index 2dc2457..b250000 100644 --- a/vhost-device-can/src/can.rs +++ b/vhost-device-can/src/can.rs @@ -64,7 +64,7 @@ impl CanController { // Creates a new controller corresponding to `device`. pub(crate) fn new(can_name: String) -> Result { let can_name = can_name.to_owned(); - info!("can_name: {:?}", can_name); + info!("can_name: {can_name:?}"); let rx_fifo = Queue::new(); let rx_efd = EventFd::new(EFD_NONBLOCK).map_err(|_| Error::EventFdFailed)?; @@ -93,10 +93,10 @@ impl CanController { let last_elem = canframe.length.to_native() as usize - 1; for (index, sdu) in canframe.sdu.iter().enumerate() { if index == last_elem { - trace!("0x{:x}", sdu); + trace!("0x{sdu:x}"); break; } - trace!("0x{:x}, ", sdu); + trace!("0x{sdu:x}, "); } trace!("]"); } @@ -198,19 +198,19 @@ impl CanController { // Match and process frame variants let read_can_frame = match frame { CanAnyFrame::Normal(frame) => { - trace!("Received CAN frame: {:?}", frame); + trace!("Received CAN frame: {frame:?}"); Self::process_frame(frame, false) } CanAnyFrame::Fd(frame) => { - trace!("Received CAN FD frame: {:?}", frame); + trace!("Received CAN FD frame: {frame:?}"); Self::process_frame(frame, true) } CanAnyFrame::Remote(frame) => { - trace!("Received Remote CAN frame: {:?}", frame); + trace!("Received Remote CAN frame: {frame:?}"); Self::process_frame(frame, false) } CanAnyFrame::Error(frame) => { - trace!("Received Error frame: {:?}", frame); + trace!("Received Error frame: {frame:?}"); Self::process_frame(frame, false) } }; @@ -354,7 +354,7 @@ mod tests { let operation_result = controller.can_out(frame); assert!(operation_result.is_ok()); } - Err(_) => warn!("There is no CAN interface with {} name", can_name), + Err(_) => warn!("There is no CAN interface with {can_name} name"), } } diff --git a/vhost-device-can/src/main.rs b/vhost-device-can/src/main.rs index 48c60de..0eb032e 100644 --- a/vhost-device-can/src/main.rs +++ b/vhost-device-can/src/main.rs @@ -40,7 +40,7 @@ struct CanArgs { fn check_can_devices(can_devices: &[String]) -> Result<()> { for can_dev in can_devices { if CanSocket::open(can_dev).is_err() { - info!("There is no interface with the following name {}", can_dev); + info!("There is no interface with the following name {can_dev}"); return Err(Error::CouldNotFindCANDevs); } } diff --git a/vhost-device-can/src/vhu_can.rs b/vhost-device-can/src/vhu_can.rs index c75ce23..f57a213 100644 --- a/vhost-device-can/src/vhu_can.rs +++ b/vhost-device-can/src/vhu_can.rs @@ -94,7 +94,7 @@ pub(crate) enum Error { impl convert::From for io::Error { fn from(e: Error) -> Self { - io::Error::new(io::ErrorKind::Other, e) + io::Error::other(e) } } @@ -130,7 +130,7 @@ impl VhostUserCanBackend { let mut flags = 0; if msg_type != VIRTIO_CAN_TX { - warn!("TX: Message type 0x{:x} unknown\n", msg_type); + warn!("TX: Message type 0x{msg_type:x} unknown\n"); return Err(Error::UnexpectedCanMsgType(msg_type)); } @@ -435,7 +435,7 @@ impl VhostUserCanBackend { } } Err(e) => { - warn!("The tx frame had the following error: {}", e); + warn!("The tx frame had the following error: {e}"); VIRTIO_CAN_RESULT_NOT_OK } }; @@ -506,7 +506,7 @@ impl VhostUserCanBackend { let can_rx = match self.check_rx_frame(response) { Ok(frame) => frame, Err(e) => { - warn!("The tx frame had the following error: {}", e); + warn!("The tx frame had the following error: {e}"); return Err(e); } };