From 1b6ddf6c56e2b46147b437c995e5442b620f1572 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Fri, 1 Aug 2025 20:55:53 +0300 Subject: [PATCH 01/14] Replace invalid dbg! use with log::debug! dbg! does not use format specifiers and prints in stderr regardless of log output. Use log::debug! instead. Signed-off-by: Manos Pitsidianakis --- vhost-device-can/src/can.rs | 4 ++-- vhost-device-i2c/src/vhu_i2c.rs | 2 +- vhost-device-rng/src/vhu_rng.rs | 2 +- vhost-device-vsock/src/thread_backend.rs | 2 +- vhost-device-vsock/src/vhu_vsock_thread.rs | 4 ++-- vhost-device-vsock/src/vsock_conn.rs | 6 +++--- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/vhost-device-can/src/can.rs b/vhost-device-can/src/can.rs index b250000e..47a1fbc7 100644 --- a/vhost-device-can/src/can.rs +++ b/vhost-device-can/src/can.rs @@ -160,7 +160,7 @@ impl CanController { pub fn read_can_socket(controller: Arc>) -> Result<()> { let can_name = &controller.read().unwrap().can_name.clone(); - dbg!("Start reading from {} socket!", &can_name); + log::debug!("Start reading from {can_name} socket!"); let socket = match CanFdSocket::open(can_name) { Ok(socket) => socket, Err(_) => { @@ -182,7 +182,7 @@ impl CanController { loop { // If the status variable is false then break and exit. if !controller.read().unwrap().status { - dbg!("exit read can thread"); + log::debug!("exit read can thread"); return Ok(()); } diff --git a/vhost-device-i2c/src/vhu_i2c.rs b/vhost-device-i2c/src/vhu_i2c.rs index f63ed010..fbc754ec 100644 --- a/vhost-device-i2c/src/vhu_i2c.rs +++ b/vhost-device-i2c/src/vhu_i2c.rs @@ -306,7 +306,7 @@ impl VhostUserBackendMut for VhostUserI2cB } fn set_event_idx(&mut self, enabled: bool) { - dbg!(self.event_idx = enabled); + self.event_idx = enabled; } fn update_memory(&mut self, mem: GuestMemoryAtomic) -> IoResult<()> { diff --git a/vhost-device-rng/src/vhu_rng.rs b/vhost-device-rng/src/vhu_rng.rs index 03475933..b6ecabf1 100644 --- a/vhost-device-rng/src/vhu_rng.rs +++ b/vhost-device-rng/src/vhu_rng.rs @@ -232,7 +232,7 @@ impl VhostUserBackendMut for VuRngBacke } fn set_event_idx(&mut self, enabled: bool) { - dbg!(self.event_idx = enabled); + self.event_idx = enabled; } fn update_memory( diff --git a/vhost-device-vsock/src/thread_backend.rs b/vhost-device-vsock/src/thread_backend.rs index 29fc1190..72cf7838 100644 --- a/vhost-device-vsock/src/thread_backend.rs +++ b/vhost-device-vsock/src/thread_backend.rs @@ -508,7 +508,7 @@ impl VsockThreadBackend { /// Enqueue RST packets to be sent to guest. fn enq_rst(&mut self) { // TODO - dbg!("New guest conn error: Enqueue RST"); + log::debug!("New guest conn error: Enqueue RST"); } } diff --git a/vhost-device-vsock/src/vhu_vsock_thread.rs b/vhost-device-vsock/src/vhu_vsock_thread.rs index c9741085..74b4dbae 100644 --- a/vhost-device-vsock/src/vhu_vsock_thread.rs +++ b/vhost-device-vsock/src/vhu_vsock_thread.rs @@ -456,7 +456,7 @@ impl VhostUserVsockThread { .push_back(ConnMapKey::new(conn.local_port, conn.peer_port)); } Err(e) => { - dbg!("Error: {:?}", e); + log::debug!("Error: {e:?}"); } } return; @@ -743,7 +743,7 @@ impl VhostUserVsockThread { ) { Ok(pkt) => pkt, Err(e) => { - dbg!("vsock: error reading TX packet: {:?}", e); + log::debug!("vsock: error reading TX packet: {e:?}"); continue; } }; diff --git a/vhost-device-vsock/src/vsock_conn.rs b/vhost-device-vsock/src/vsock_conn.rs index c52d2c08..39bbba4f 100644 --- a/vhost-device-vsock/src/vsock_conn.rs +++ b/vhost-device-vsock/src/vsock_conn.rs @@ -252,7 +252,7 @@ impl VsockCon Some(buf) => { if let Err(err) = self.send_bytes(buf) { // TODO: Terminate this connection - dbg!("err:{:?}", err); + log::debug!("err:{err:?}"); return Ok(()); } } @@ -318,12 +318,12 @@ impl VsockCon if e.kind() == ErrorKind::WouldBlock { 0 } else { - dbg!("send_bytes error: {:?}", e); + log::debug!("send_bytes error: {e:?}"); return Err(Error::StreamWrite); } } Err(e) => { - dbg!("send_bytes error: {:?}", e); + log::debug!("send_bytes error: {e:?}"); return Err(Error::StreamWrite); } }; From 71ce40b8d1beac817909591ea4d7b86d519c9801 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Fri, 1 Aug 2025 21:06:51 +0300 Subject: [PATCH 02/14] Replace ptr casts with typed cast() method Replace type inferred raw pointer casts with .cast() method calls to make intent clearer. Signed-off-by: Manos Pitsidianakis --- vhost-device-can/src/vhu_can.rs | 3 ++- vhost-device-gpio/src/vhu_gpio.rs | 5 +++-- vhost-device-scsi/src/vhu_scsi.rs | 2 +- vhost-device-spi/src/vhu_spi.rs | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/vhost-device-can/src/vhu_can.rs b/vhost-device-can/src/vhu_can.rs index f57a2137..a2de02f7 100644 --- a/vhost-device-can/src/vhu_can.rs +++ b/vhost-device-can/src/vhu_can.rs @@ -637,7 +637,8 @@ impl VhostUserBackendMut for VhostUserCanBackend { .config() .as_slice() .as_ptr() - .offset(offset as isize) as *const _ as *const _, + .offset(offset as isize) + .cast::(), size as usize, ) .to_vec() diff --git a/vhost-device-gpio/src/vhu_gpio.rs b/vhost-device-gpio/src/vhu_gpio.rs index c0683caf..6b6df583 100644 --- a/vhost-device-gpio/src/vhu_gpio.rs +++ b/vhost-device-gpio/src/vhu_gpio.rs @@ -421,7 +421,8 @@ impl VhostUserBackendMut for VhostUserGpi .config() .as_slice() .as_ptr() - .offset(offset as isize) as *const _ as *const _, + .offset(offset as isize) + .cast::(), size as usize, ) .to_vec() @@ -1157,7 +1158,7 @@ mod tests { // reading its content from byte array. unsafe { from_raw_parts( - &config as *const _ as *const _, + (&raw const config).cast::(), size_of::(), ) .to_vec() diff --git a/vhost-device-scsi/src/vhu_scsi.rs b/vhost-device-scsi/src/vhu_scsi.rs index 1e7c04d2..628bafc8 100644 --- a/vhost-device-scsi/src/vhu_scsi.rs +++ b/vhost-device-scsi/src/vhu_scsi.rs @@ -298,7 +298,7 @@ impl VhostUserBackendMut for VhostUserScsiBackend { // access up to the size of the struct. let config_slice = unsafe { slice::from_raw_parts( - &config as *const virtio_scsi_config as *const u8, + (&raw const config).cast::(), mem::size_of::(), ) }; diff --git a/vhost-device-spi/src/vhu_spi.rs b/vhost-device-spi/src/vhu_spi.rs index e90a8017..a1ebdf30 100644 --- a/vhost-device-spi/src/vhu_spi.rs +++ b/vhost-device-spi/src/vhu_spi.rs @@ -1423,7 +1423,7 @@ mod tests { // reading its content from byte array. unsafe { from_raw_parts( - &dummy_config as *const _ as *const _, + (&raw const dummy_config).cast::(), size_of::(), ) .to_vec() From 0fd65fc458ecc88b80a6582dadc44e7602ddb2c6 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Fri, 1 Aug 2025 21:12:00 +0300 Subject: [PATCH 03/14] input: replace fallible integer cast with try_into casting usize as i32 might wrap around in 32-bit targets, we don't target them, but clippy complains. Signed-off-by: Manos Pitsidianakis --- vhost-device-input/src/input.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vhost-device-input/src/input.rs b/vhost-device-input/src/input.rs index ccf1f2f4..ae2b94c9 100644 --- a/vhost-device-input/src/input.rs +++ b/vhost-device-input/src/input.rs @@ -64,7 +64,7 @@ macro_rules! ioctl_read_buf { for item in data.iter_mut() { *item = $nr as u8; } - Ok(data.len() as i32) + Ok(data.len().try_into().unwrap()) } ) } From 9f92de3c3e67cc2ba6a133b51deee9ab28d6c475 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Fri, 1 Aug 2025 21:13:52 +0300 Subject: [PATCH 04/14] Add workspace-wide lints Crates need to opt-in by setting: [lints] workspace = true In their Cargo.toml file. Signed-off-by: Manos Pitsidianakis --- Cargo.toml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 3251c06b..b596219c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,3 +17,39 @@ members = [ "vhost-device-vsock", "xtask", ] + +[workspace.lints.rust] +unsafe_op_in_unsafe_fn = "deny" + +[workspace.lints.rustdoc] +broken_intra_doc_links = "deny" +redundant_explicit_links = "deny" + +[workspace.lints.clippy] +enum_glob_use = "deny" +# groups +correctness = { level = "deny", priority = -1 } +suspicious = { level = "deny", priority = -1 } +complexity = { level = "deny", priority = -1 } +perf = { level = "deny", priority = -1 } +style = { level = "deny", priority = -1 } +#nursery = { level = "deny", priority = -1 } +# restriction +dbg_macro = "deny" +rc_buffer = "deny" +as_underscore = "deny" +assertions_on_result_states = "deny" +# pedantic +cast_lossless = "deny" +cast_possible_wrap = "deny" +cast_ptr_alignment = "deny" +naive_bytecount = "deny" +ptr_as_ptr = "deny" +bool_to_int_with_if = "deny" +borrow_as_ptr = "deny" +case_sensitive_file_extension_comparisons = "deny" +significant_drop_in_scrutinee = "allow" +significant_drop_tightening = "allow" +missing_safety_doc = "deny" +undocumented_unsafe_blocks = "deny" +option_if_let_else = "allow" From c4d66587f1f6807fe4316ebc6c885739c97552c9 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Fri, 1 Aug 2025 21:15:20 +0300 Subject: [PATCH 05/14] console: enable workspace-wide lints Signed-off-by: Manos Pitsidianakis --- vhost-device-console/Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vhost-device-console/Cargo.toml b/vhost-device-console/Cargo.toml index 44b2e291..bb1bdefd 100644 --- a/vhost-device-console/Cargo.toml +++ b/vhost-device-console/Cargo.toml @@ -34,3 +34,6 @@ vmm-sys-util = "0.14" assert_matches = "1.5" virtio-queue = { version = "0.16", features = ["test-utils"] } vm-memory = { version = "0.16.1", features = ["backend-mmap", "backend-atomic"] } + +[lints] +workspace = true From e0c6313355c7b680649c3afb04bb25145d8e5dde Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Fri, 1 Aug 2025 21:17:56 +0300 Subject: [PATCH 06/14] template: enable workspace-wide lints Signed-off-by: Manos Pitsidianakis --- vhost-device-template/Cargo.toml | 3 +++ vhost-device-template/src/vhu_foo.rs | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/vhost-device-template/Cargo.toml b/vhost-device-template/Cargo.toml index 35b87628..1453572f 100644 --- a/vhost-device-template/Cargo.toml +++ b/vhost-device-template/Cargo.toml @@ -32,3 +32,6 @@ vmm-sys-util = "0.14" assert_matches = "1.5" virtio-queue = { version = "0.16", features = ["test-utils"] } vm-memory = { version = "0.16.1", features = ["backend-mmap", "backend-atomic"] } + +[lints] +workspace = true diff --git a/vhost-device-template/src/vhu_foo.rs b/vhost-device-template/src/vhu_foo.rs index 8d87405e..20879ed2 100644 --- a/vhost-device-template/src/vhu_foo.rs +++ b/vhost-device-template/src/vhu_foo.rs @@ -293,7 +293,7 @@ mod tests { VRING_DESC_F_NEXT as u16, index + 1, ); - next_addr += desc_out.len() as u64; + next_addr += u64::from(desc_out.len()); index += 1; mem.write_obj::(out_hdr, desc_out.addr()) @@ -308,7 +308,7 @@ mod tests { (VRING_DESC_F_WRITE | VRING_DESC_F_NEXT) as u16, index + 1, ); - next_addr += desc_buf.len() as u64; + next_addr += u64::from(desc_buf.len()); mem.write(buf, desc_buf.addr()).unwrap(); descriptors.push(desc_buf); From ef4b2199fe7559fb555f9f655379c485ed26c65b Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Fri, 1 Aug 2025 21:18:34 +0300 Subject: [PATCH 07/14] vsock: enable workspace-wide lints Signed-off-by: Manos Pitsidianakis --- vhost-device-vsock/Cargo.toml | 3 ++ vhost-device-vsock/src/thread_backend.rs | 22 ++++++------- vhost-device-vsock/src/txbuf.rs | 10 +++--- vhost-device-vsock/src/vhu_vsock.rs | 10 +++--- vhost-device-vsock/src/vhu_vsock_thread.rs | 34 +++++++++----------- vhost-device-vsock/src/vsock_conn.rs | 36 +++++++++++----------- 6 files changed, 57 insertions(+), 58 deletions(-) diff --git a/vhost-device-vsock/Cargo.toml b/vhost-device-vsock/Cargo.toml index 149df3a7..b361b0ca 100644 --- a/vhost-device-vsock/Cargo.toml +++ b/vhost-device-vsock/Cargo.toml @@ -37,3 +37,6 @@ serde = { version = "1", features = ["derive"] } assert_matches = "1.5" virtio-queue = { version = "0.16", features = ["test-utils"] } tempfile = "3.20.0" + +[lints] +workspace = true diff --git a/vhost-device-vsock/src/thread_backend.rs b/vhost-device-vsock/src/thread_backend.rs index 72cf7838..44a1f1e1 100644 --- a/vhost-device-vsock/src/thread_backend.rs +++ b/vhost-device-vsock/src/thread_backend.rs @@ -563,26 +563,26 @@ mod tests { Error::EmptyBackendRxQ.to_string() ); - assert!(vtp.send_pkt(&packet).is_ok()); + vtp.send_pkt(&packet).unwrap(); packet.set_type(VSOCK_TYPE_STREAM); - assert!(vtp.send_pkt(&packet).is_ok()); + vtp.send_pkt(&packet).unwrap(); packet.set_src_cid(CID); packet.set_dst_cid(VSOCK_HOST_CID); packet.set_dst_port(VSOCK_PEER_PORT); - assert!(vtp.send_pkt(&packet).is_ok()); + vtp.send_pkt(&packet).unwrap(); packet.set_op(VSOCK_OP_REQUEST); - assert!(vtp.send_pkt(&packet).is_ok()); + vtp.send_pkt(&packet).unwrap(); packet.set_op(VSOCK_OP_RW); - assert!(vtp.send_pkt(&packet).is_ok()); + vtp.send_pkt(&packet).unwrap(); packet.set_op(VSOCK_OP_RST); - assert!(vtp.send_pkt(&packet).is_ok()); + vtp.send_pkt(&packet).unwrap(); - assert!(vtp.recv_pkt(&mut packet).is_ok()); + vtp.recv_pkt(&mut packet).unwrap(); // TODO: it is a nop for now vtp.enq_rst(); @@ -714,7 +714,7 @@ mod tests { .unwrap() .copy_from(&[0xCAu8, 0xFEu8, 0xBAu8, 0xBEu8]); - assert!(vtp.send_pkt(&packet).is_ok()); + vtp.send_pkt(&packet).unwrap(); assert!(sibling_backend.threads[0] .lock() .unwrap() @@ -722,7 +722,7 @@ mod tests { .pending_raw_pkts()); packet.set_dst_cid(SIBLING2_CID); - assert!(vtp.send_pkt(&packet).is_ok()); + vtp.send_pkt(&packet).unwrap(); // packet should be discarded since sibling2 is not in the same group assert!(!sibling2_backend.threads[0] .lock() @@ -737,12 +737,12 @@ mod tests { // SAFETY: Safe as recvd_hdr_raw and recvd_data_raw are guaranteed to be valid. unsafe { VsockPacket::new(recvd_hdr_raw, Some(recvd_data_raw)).unwrap() }; - assert!(sibling_backend.threads[0] + sibling_backend.threads[0] .lock() .unwrap() .thread_backend .recv_raw_pkt(&mut recvd_packet) - .is_ok()); + .unwrap(); assert_eq!(recvd_packet.type_(), VSOCK_TYPE_STREAM); assert_eq!(recvd_packet.src_cid(), CID); diff --git a/vhost-device-vsock/src/txbuf.rs b/vhost-device-vsock/src/txbuf.rs index ad6a6f65..77e93c9a 100644 --- a/vhost-device-vsock/src/txbuf.rs +++ b/vhost-device-vsock/src/txbuf.rs @@ -147,7 +147,7 @@ mod tests { // push data into empty tx buffer let res_push = loc_tx_buf.push(&data); - assert!(res_push.is_ok()); + res_push.unwrap(); assert_eq!(loc_tx_buf.head, Wrapping(0)); assert_eq!(loc_tx_buf.tail, Wrapping(CONN_TX_BUF_SIZE)); @@ -158,7 +158,7 @@ mod tests { // head and tail wrap at full loc_tx_buf.head = Wrapping(CONN_TX_BUF_SIZE); let res_push = loc_tx_buf.push(&data); - assert!(res_push.is_ok()); + res_push.unwrap(); assert_eq!(loc_tx_buf.tail, Wrapping(CONN_TX_BUF_SIZE * 2)); // only tail wraps at full @@ -168,7 +168,7 @@ mod tests { loc_tx_buf.head = Wrapping(2); loc_tx_buf.tail = Wrapping(CONN_TX_BUF_SIZE - 2); let res_push = loc_tx_buf.push(&data); - assert!(res_push.is_ok()); + res_push.unwrap(); assert_eq!(loc_tx_buf.head, Wrapping(2)); assert_eq!(loc_tx_buf.tail, Wrapping(CONN_TX_BUF_SIZE + 2)); assert_eq!(loc_tx_buf.buf[0..2], buf[2..4]); @@ -197,7 +197,7 @@ mod tests { // flush data of CONN_TX_BUF_SIZE amount let res_push = loc_tx_buf.push(&data); - assert!(res_push.is_ok()); + res_push.unwrap(); let res_flush = loc_tx_buf.flush_to(&mut cmp_vec); if let Ok(n) = res_flush { assert_eq!(loc_tx_buf.head, Wrapping(n as u32)); @@ -215,7 +215,7 @@ mod tests { loc_tx_buf.head = Wrapping(0); loc_tx_buf.tail = Wrapping(0); let res_push = loc_tx_buf.push(&data); - assert!(res_push.is_ok()); + res_push.unwrap(); cmp_vec.clear(); loc_tx_buf.head = Wrapping(CONN_TX_BUF_SIZE / 2); loc_tx_buf.tail = Wrapping(CONN_TX_BUF_SIZE + (CONN_TX_BUF_SIZE / 2)); diff --git a/vhost-device-vsock/src/vhu_vsock.rs b/vhost-device-vsock/src/vhu_vsock.rs index 8e72c2f2..00bc9d69 100644 --- a/vhost-device-vsock/src/vhu_vsock.rs +++ b/vhost-device-vsock/src/vhu_vsock.rs @@ -434,7 +434,7 @@ mod tests { vrings[1].set_queue_info(0x1100, 0x1200, 0x1300).unwrap(); vrings[1].set_queue_ready(true); - assert!(backend.update_memory(mem).is_ok()); + backend.update_memory(mem).unwrap(); let queues_per_thread = backend.queues_per_thread(); assert_eq!(queues_per_thread.len(), 1); @@ -450,16 +450,16 @@ mod tests { exit.unwrap().write(1).unwrap(); let ret = backend.handle_event(RX_QUEUE_EVENT, EventSet::IN, &vrings, 0); - assert!(ret.is_ok()); + ret.unwrap(); let ret = backend.handle_event(TX_QUEUE_EVENT, EventSet::IN, &vrings, 0); - assert!(ret.is_ok()); + ret.unwrap(); let ret = backend.handle_event(EVT_QUEUE_EVENT, EventSet::IN, &vrings, 0); - assert!(ret.is_ok()); + ret.unwrap(); let ret = backend.handle_event(BACKEND_EVENT, EventSet::IN, &vrings, 0); - assert!(ret.is_ok()); + ret.unwrap(); } #[test] diff --git a/vhost-device-vsock/src/vhu_vsock_thread.rs b/vhost-device-vsock/src/vhu_vsock_thread.rs index 74b4dbae..07997282 100644 --- a/vhost-device-vsock/src/vhu_vsock_thread.rs +++ b/vhost-device-vsock/src/vhu_vsock_thread.rs @@ -861,40 +861,36 @@ mod tests { let dummy_fd = EventFd::new(0).unwrap(); - assert!(VhostUserVsockThread::epoll_register( - epoll_fd, - dummy_fd.as_raw_fd(), - epoll::Events::EPOLLOUT - ) - .is_ok()); - assert!(VhostUserVsockThread::epoll_modify( + VhostUserVsockThread::epoll_register( epoll_fd, dummy_fd.as_raw_fd(), - epoll::Events::EPOLLIN + epoll::Events::EPOLLOUT, ) - .is_ok()); - assert!(VhostUserVsockThread::epoll_unregister(epoll_fd, dummy_fd.as_raw_fd()).is_ok()); - assert!(VhostUserVsockThread::epoll_register( + .unwrap(); + VhostUserVsockThread::epoll_modify(epoll_fd, dummy_fd.as_raw_fd(), epoll::Events::EPOLLIN) + .unwrap(); + VhostUserVsockThread::epoll_unregister(epoll_fd, dummy_fd.as_raw_fd()).unwrap(); + VhostUserVsockThread::epoll_register( epoll_fd, dummy_fd.as_raw_fd(), - epoll::Events::EPOLLIN + epoll::Events::EPOLLIN, ) - .is_ok()); + .unwrap(); let vring = VringRwLock::new(mem, 0x1000).unwrap(); vring.set_queue_info(0x100, 0x200, 0x300).unwrap(); vring.set_queue_ready(true); - assert!(t.process_tx(&vring, false).is_ok()); - assert!(t.process_tx(&vring, true).is_ok()); + t.process_tx(&vring, false).unwrap(); + t.process_tx(&vring, true).unwrap(); // add backend_rxq to avoid that RX processing is skipped t.thread_backend .backend_rxq .push_back(ConnMapKey::new(0, 0)); - assert!(t.process_rx(&vring, false).is_ok()); - assert!(t.process_rx(&vring, true).is_ok()); - assert!(t.process_raw_pkts(&vring, false).is_ok()); - assert!(t.process_raw_pkts(&vring, true).is_ok()); + t.process_rx(&vring, false).unwrap(); + t.process_rx(&vring, true).unwrap(); + t.process_raw_pkts(&vring, false).unwrap(); + t.process_raw_pkts(&vring, true).unwrap(); VhostUserVsockThread::vring_handle_event(EventData { vring: vring.clone(), diff --git a/vhost-device-vsock/src/vsock_conn.rs b/vhost-device-vsock/src/vsock_conn.rs index 39bbba4f..aee4fc12 100644 --- a/vhost-device-vsock/src/vsock_conn.rs +++ b/vhost-device-vsock/src/vsock_conn.rs @@ -473,7 +473,7 @@ mod tests { )); mem.write(&header, SplitDescriptor::from(head_desc).addr()) .unwrap(); - assert!(virt_queue.desc_table().store(0, head_desc).is_ok()); + virt_queue.desc_table().store(0, head_desc).unwrap(); next_addr += head_params.head_len as u64; // Put the descriptor index 0 in the first available ring position. @@ -500,8 +500,8 @@ mod tests { )); mem.write(&data, SplitDescriptor::from(data_desc).addr()) .unwrap(); - assert!(virt_queue.desc_table().store(i + 1, data_desc).is_ok()); - next_addr += head_data_len as u64; + virt_queue.desc_table().store(i + 1, data_desc).unwrap(); + next_addr += u64::from(head_data_len); } // Create descriptor chain from pre-filled memory @@ -625,7 +625,7 @@ mod tests { fn test_vsock_conn_init() { // new locally inititated connection let mut dummy_file = VsockDummySocket::new(); - assert!(dummy_file.flush().is_ok()); + dummy_file.flush().unwrap(); let mut conn_local = VsockConnection::new_local_init( dummy_file, VSOCK_HOST_CID, @@ -761,14 +761,14 @@ mod tests { // VSOCK_OP_REQUEST: new local conn request conn_local.rx_queue.enqueue(RxOps::Request); let op_req = conn_local.recv_pkt(&mut pkt); - assert!(op_req.is_ok()); + op_req.unwrap(); assert!(!conn_local.rx_queue.pending_rx()); assert_eq!(pkt.op(), VSOCK_OP_REQUEST); // VSOCK_OP_RST: reset if connection not established conn_local.rx_queue.enqueue(RxOps::Rw); let op_rst = conn_local.recv_pkt(&mut pkt); - assert!(op_rst.is_ok()); + op_rst.unwrap(); assert!(!conn_local.rx_queue.pending_rx()); assert_eq!(pkt.op(), VSOCK_OP_RST); @@ -777,7 +777,7 @@ mod tests { conn_local.rx_queue.enqueue(RxOps::Rw); conn_local.fwd_cnt = Wrapping(1024); let op_credit_update = conn_local.recv_pkt(&mut pkt); - assert!(op_credit_update.is_ok()); + op_credit_update.unwrap(); assert!(!conn_local.rx_queue.pending_rx()); assert_eq!(pkt.op(), VSOCK_OP_CREDIT_REQUEST); assert_eq!(conn_local.last_fwd_cnt, Wrapping(1024)); @@ -786,7 +786,7 @@ mod tests { conn_local.peer_buf_alloc = 65536; conn_local.rx_queue.enqueue(RxOps::Rw); let op_zero_read_shutdown = conn_local.recv_pkt(&mut pkt); - assert!(op_zero_read_shutdown.is_ok()); + op_zero_read_shutdown.unwrap(); assert!(!conn_local.rx_queue.pending_rx()); assert_eq!(conn_local.rx_cnt, Wrapping(0)); assert_eq!(conn_local.last_fwd_cnt, Wrapping(1024)); @@ -801,20 +801,20 @@ mod tests { host_socket.write_all(payload).unwrap(); conn_local.rx_queue.enqueue(RxOps::Rw); let op_zero_read = conn_local.recv_pkt(&mut pkt); - assert!(op_zero_read.is_ok()); + op_zero_read.unwrap(); assert_eq!(pkt.op(), VSOCK_OP_RW); assert!(!conn_local.rx_queue.pending_rx()); assert_eq!(conn_local.rx_cnt, Wrapping(payload.len() as u32)); assert_eq!(conn_local.last_fwd_cnt, Wrapping(1024)); assert_eq!(pkt.len(), 5); let buf = &mut [0u8; 5]; - assert!(pkt.data_slice().unwrap().read_slice(buf, 0).is_ok()); + pkt.data_slice().unwrap().read_slice(buf, 0).unwrap(); assert_eq!(buf, b"hello"); // VSOCK_OP_RESPONSE: response from a locally initiated connection conn_local.rx_queue.enqueue(RxOps::Response); let op_response = conn_local.recv_pkt(&mut pkt); - assert!(op_response.is_ok()); + op_response.unwrap(); assert!(!conn_local.rx_queue.pending_rx()); assert_eq!(pkt.op(), VSOCK_OP_RESPONSE); assert!(conn_local.connect); @@ -823,7 +823,7 @@ mod tests { conn_local.rx_queue.enqueue(RxOps::CreditUpdate); let op_credit_update = conn_local.recv_pkt(&mut pkt); assert!(!conn_local.rx_queue.pending_rx()); - assert!(op_credit_update.is_ok()); + op_credit_update.unwrap(); assert_eq!(pkt.op(), VSOCK_OP_CREDIT_UPDATE); assert_eq!(conn_local.last_fwd_cnt, Wrapping(1024)); @@ -861,7 +861,7 @@ mod tests { // check if peer credit information is updated currently let credit_check = conn_local.send_pkt(&pkt); - assert!(credit_check.is_ok()); + credit_check.unwrap(); assert_eq!(conn_local.peer_buf_alloc, 65536); assert_eq!(conn_local.peer_fwd_cnt, Wrapping(1024)); @@ -869,7 +869,7 @@ mod tests { pkt.set_op(VSOCK_OP_RESPONSE); assert_eq!(conn_local.peer_port, 5001); let peer_response = conn_local.send_pkt(&pkt); - assert!(peer_response.is_ok()); + peer_response.unwrap(); assert!(conn_local.connect); let mut resp_buf = vec![0; 8]; host_socket.read_exact(&mut resp_buf).unwrap(); @@ -878,9 +878,9 @@ mod tests { // VSOCK_OP_RW pkt.set_op(VSOCK_OP_RW); let buf = b"hello"; - assert!(pkt.data_slice().unwrap().write_slice(buf, 0).is_ok()); + pkt.data_slice().unwrap().write_slice(buf, 0).unwrap(); let rw_response = conn_local.send_pkt(&pkt); - assert!(rw_response.is_ok()); + rw_response.unwrap(); let mut resp_buf = vec![0; 5]; host_socket.read_exact(&mut resp_buf).unwrap(); assert_eq!(resp_buf, b"hello"); @@ -888,14 +888,14 @@ mod tests { // VSOCK_OP_CREDIT_REQUEST pkt.set_op(VSOCK_OP_CREDIT_REQUEST); let credit_response = conn_local.send_pkt(&pkt); - assert!(credit_response.is_ok()); + credit_response.unwrap(); assert_eq!(conn_local.rx_queue.peek().unwrap(), RxOps::CreditUpdate); // VSOCK_OP_SHUTDOWN pkt.set_op(VSOCK_OP_SHUTDOWN); pkt.set_flags(VSOCK_FLAGS_SHUTDOWN_RCV | VSOCK_FLAGS_SHUTDOWN_SEND); let shutdown_response = conn_local.send_pkt(&pkt); - assert!(shutdown_response.is_ok()); + shutdown_response.unwrap(); assert!(conn_local.rx_queue.contains(RxOps::Reset.bitmask())); } } From aec935fe42bb885d84544851077763f5d6bbd8d4 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Fri, 1 Aug 2025 21:18:48 +0300 Subject: [PATCH 08/14] i2c: enable workspace-wide lints Signed-off-by: Manos Pitsidianakis --- vhost-device-i2c/Cargo.toml | 3 +++ vhost-device-i2c/src/i2c.rs | 3 ++- vhost-device-i2c/src/vhu_i2c.rs | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/vhost-device-i2c/Cargo.toml b/vhost-device-i2c/Cargo.toml index fc2ba960..1151a814 100644 --- a/vhost-device-i2c/Cargo.toml +++ b/vhost-device-i2c/Cargo.toml @@ -31,3 +31,6 @@ vmm-sys-util = "0.14" assert_matches = "1.5" virtio-queue = { version = "0.16", features = ["test-utils"] } vm-memory = { version = "0.16.1", features = ["backend-mmap", "backend-atomic"] } + +[lints] +workspace = true diff --git a/vhost-device-i2c/src/i2c.rs b/vhost-device-i2c/src/i2c.rs index c6064b65..4fd281ce 100644 --- a/vhost-device-i2c/src/i2c.rs +++ b/vhost-device-i2c/src/i2c.rs @@ -242,7 +242,8 @@ impl SmbusMsg { // Special Read requests, reqs[0].len can be 0 or 1 only. Err(Error::MessageLengthInvalid("read", 3)) } else { - data.word = reqs[0].buf[1] as u16 | ((reqs[0].buf[2] as u16) << 8); + data.word = + u16::from(reqs[0].buf[1]) | (u16::from(reqs[0].buf[2]) << 8); Ok(SmbusMsg { read_write, command: reqs[0].buf[0], diff --git a/vhost-device-i2c/src/vhu_i2c.rs b/vhost-device-i2c/src/vhu_i2c.rs index fbc754ec..c4d7ffde 100644 --- a/vhost-device-i2c/src/vhu_i2c.rs +++ b/vhost-device-i2c/src/vhu_i2c.rs @@ -407,7 +407,7 @@ mod tests { vq.desc_table() .store(index, RawDescriptor::from(desc_out)) .unwrap(); - next_addr += desc_out.len() as u64; + next_addr += u64::from(desc_out.len()); index += 1; // Buf descriptor: optional @@ -430,7 +430,7 @@ mod tests { vq.desc_table() .store(index, RawDescriptor::from(desc_buf)) .unwrap(); - next_addr += desc_buf.len() as u64; + next_addr += u64::from(desc_buf.len()); index += 1; } From c30ccf8ab721e4999713f9e7872a850793dd3721 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Fri, 1 Aug 2025 21:19:05 +0300 Subject: [PATCH 09/14] input: enable workspace-wide lints Signed-off-by: Manos Pitsidianakis --- vhost-device-input/Cargo.toml | 3 +++ vhost-device-input/src/vhu_input.rs | 22 ++++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/vhost-device-input/Cargo.toml b/vhost-device-input/Cargo.toml index 69ab5218..a3d22cf5 100644 --- a/vhost-device-input/Cargo.toml +++ b/vhost-device-input/Cargo.toml @@ -35,3 +35,6 @@ nix = { version = "0.30", features = ["ioctl"] } assert_matches = "1.5" virtio-queue = { version = "0.16", features = ["test-utils"] } vm-memory = { version = "0.16", features = ["backend-mmap", "backend-atomic"] } + +[lints] +workspace = true diff --git a/vhost-device-input/src/vhu_input.rs b/vhost-device-input/src/vhu_input.rs index 5f37ea30..4456b654 100644 --- a/vhost-device-input/src/vhu_input.rs +++ b/vhost-device-input/src/vhu_input.rs @@ -148,7 +148,9 @@ impl VuInputBackend { let last_sync_index = self .ev_list .iter() - .rposition(|event| event.ev_type == EV_SYN as u16 && event.code == SYN_REPORT as u16) + .rposition(|event| { + event.ev_type == u16::from(EV_SYN) && event.code == u16::from(SYN_REPORT) + }) .unwrap_or(0); if last_sync_index == 0 { @@ -609,15 +611,15 @@ mod tests { .unwrap(); let ev_raw_data = VuInputEvent { - ev_type: EV_KEY as u16, - code: SYN_REPORT as u16, + ev_type: u16::from(EV_KEY), + code: u16::from(SYN_REPORT), value: 0, }; backend.ev_list.push_back(ev_raw_data); let ev_raw_data = VuInputEvent { - ev_type: EV_SYN as u16, - code: SYN_REPORT as u16, + ev_type: u16::from(EV_SYN), + code: u16::from(SYN_REPORT), value: 0, }; backend.ev_list.push_back(ev_raw_data); @@ -630,15 +632,15 @@ mod tests { assert_eq!(backend.ev_list.len(), 0); let ev_raw_data = VuInputEvent { - ev_type: EV_KEY as u16, - code: SYN_REPORT as u16, + ev_type: u16::from(EV_KEY), + code: u16::from(SYN_REPORT), value: 0, }; backend.ev_list.push_back(ev_raw_data); let ev_raw_data = VuInputEvent { - ev_type: EV_SYN as u16, - code: SYN_REPORT as u16, + ev_type: u16::from(EV_SYN), + code: u16::from(SYN_REPORT), value: 0, }; backend.ev_list.push_back(ev_raw_data); @@ -854,7 +856,7 @@ mod tests { assert_eq!(backend.queues_per_thread(), vec![0xffff_ffff]); assert_eq!(backend.get_config(0, 0), vec![]); - assert!(backend.update_memory(mem.clone()).is_ok()); + backend.update_memory(mem.clone()).unwrap(); backend.set_event_idx(true); assert!(backend.event_idx); From 9f50e6c8d3de9bad4eb2090442afe86b5f250999 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Fri, 1 Aug 2025 21:19:17 +0300 Subject: [PATCH 10/14] rng: enable workspace-wide lints Signed-off-by: Manos Pitsidianakis --- vhost-device-rng/Cargo.toml | 3 +++ vhost-device-rng/src/vhu_rng.rs | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/vhost-device-rng/Cargo.toml b/vhost-device-rng/Cargo.toml index 81b9b065..0be18b94 100644 --- a/vhost-device-rng/Cargo.toml +++ b/vhost-device-rng/Cargo.toml @@ -32,3 +32,6 @@ vmm-sys-util = "0.14" assert_matches = "1.5" virtio-queue = { version = "0.16", features = ["test-utils"] } vm-memory = { version = "0.16", features = ["backend-mmap", "backend-atomic"] } + +[lints] +workspace = true diff --git a/vhost-device-rng/src/vhu_rng.rs b/vhost-device-rng/src/vhu_rng.rs index b6ecabf1..7dfa3566 100644 --- a/vhost-device-rng/src/vhu_rng.rs +++ b/vhost-device-rng/src/vhu_rng.rs @@ -369,7 +369,7 @@ mod tests { }; let desc = RawDescriptor::from(SplitDescriptor::new( - (0x100 * (i + 1)) as u64, + u64::from(0x100 * (i + 1)), 0x200, desc_flags, i + 1, @@ -579,7 +579,7 @@ mod tests { assert_eq!(backend.queues_per_thread(), vec![0xffff_ffff]); assert_eq!(backend.get_config(0, 0), vec![]); - assert!(backend.update_memory(mem).is_ok()); + backend.update_memory(mem).unwrap(); backend.set_event_idx(true); assert!(backend.event_idx); From 9dc2098fc3f6f810a0f1f45812d73a6e5ff0570d Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Fri, 1 Aug 2025 21:19:44 +0300 Subject: [PATCH 11/14] scmi: enable workspace-wide lints Signed-off-by: Manos Pitsidianakis --- vhost-device-scmi/Cargo.toml | 5 ++++- vhost-device-scmi/src/devices/iio.rs | 8 ++++---- vhost-device-scmi/src/scmi.rs | 10 +++++----- vhost-device-scmi/src/vhu_scmi.rs | 2 +- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/vhost-device-scmi/Cargo.toml b/vhost-device-scmi/Cargo.toml index c3f7cdac..83de8003 100644 --- a/vhost-device-scmi/Cargo.toml +++ b/vhost-device-scmi/Cargo.toml @@ -24,4 +24,7 @@ vmm-sys-util = "0.14" [dev-dependencies] assert_matches = "1.5" -virtio-queue = { version = "0.16", features = ["test-utils"] } \ No newline at end of file +virtio-queue = { version = "0.16", features = ["test-utils"] } + +[lints] +workspace = true diff --git a/vhost-device-scmi/src/devices/iio.rs b/vhost-device-scmi/src/devices/iio.rs index 82e7880b..0c997fa2 100644 --- a/vhost-device-scmi/src/devices/iio.rs +++ b/vhost-device-scmi/src/devices/iio.rs @@ -442,7 +442,7 @@ impl SensorT for IIOSensor { return Err(ScmiDeviceError::GenericError); } - let sample_byte = (scan_type.realbits as f64 / 8_f64).ceil() as usize; + let sample_byte = (f64::from(scan_type.realbits) / 8_f64).ceil() as usize; let sample_buffer_len = sample_byte * self.axes.len(); let mut buffer = vec![0u8; sample_buffer_len]; let mut file = self.sensor().notify_dev.as_ref().unwrap(); @@ -467,7 +467,7 @@ impl SensorT for IIOSensor { let value = i16::from_le_bytes(buffer[i * 2..i * 2 + 2].try_into().unwrap()); let value_i64 = self - .deal_axis_raw_data(value as i64, &self.axes[i]) + .deal_axis_raw_data(i64::from(value), &self.axes[i]) .unwrap(); let sensor_value_low = (value_i64 & 0xffff_ffff) as i32; let sensor_value_high = (value_i64 >> 32) as i32; @@ -607,10 +607,10 @@ impl IIOSensor { custom_exponent -= 1; // Calculate the resolution of scale custom_resolution = - (scale * 10i32.pow(-custom_exponent as u32) as f64).trunc() as u64; + (scale * f64::from(10i32.pow(-custom_exponent as u32))).trunc() as u64; } else { custom_resolution = - (scale / 10i32.pow(custom_exponent as u32) as f64).trunc() as u64; + (scale / f64::from(10i32.pow(custom_exponent as u32))).trunc() as u64; } // The SCMI exponent (unit_exponent + custom_exponent) can have max. 5 bits: custom_exponent = min(15 - unit_exponent, custom_exponent); diff --git a/vhost-device-scmi/src/scmi.rs b/vhost-device-scmi/src/scmi.rs index 3c9a8be5..da304632 100644 --- a/vhost-device-scmi/src/scmi.rs +++ b/vhost-device-scmi/src/scmi.rs @@ -778,9 +778,9 @@ impl ScmiHandler { // message_type = 0x3 [9:8] // protocol_id=0x15; [17:10] // 0x1 | (0x3<<8) | (0x15<<10) - let notify_header: MessageHeader = (SENSOR_UPDATE as u32) + let notify_header: MessageHeader = u32::from(SENSOR_UPDATE) | ((MessageType::Notification as u32) << 8) - | ((SENSOR_PROTOCOL_ID as u32) << 10); + | (u32::from(SENSOR_PROTOCOL_ID) << 10); Some(ScmiResponse::from( notify_header, @@ -1564,12 +1564,12 @@ mod tests { for iteration in 0..2 { for sensor_id in 0..2 { let notification = handler.notify(NOTIFY_ALLOW_START_FD + sensor_id).unwrap(); - let notify_header: MessageHeader = (SENSOR_UPDATE as u32) + let notify_header: MessageHeader = u32::from(SENSOR_UPDATE) | ((MessageType::Notification as u32) << 8) - | ((SENSOR_PROTOCOL_ID as u32) << 10); + | (u32::from(SENSOR_PROTOCOL_ID) << 10); let mut result = vec![]; result.push(MessageValue::Unsigned(0)); - result.push(MessageValue::Unsigned(sensor_id as u32)); + result.push(MessageValue::Unsigned(u32::from(sensor_id))); for i in 0..3 { result.push(MessageValue::Signed(iteration + 100 * i)); result.push(MessageValue::Signed(0)); diff --git a/vhost-device-scmi/src/vhu_scmi.rs b/vhost-device-scmi/src/vhu_scmi.rs index 507eeaa9..73bf1ae0 100644 --- a/vhost-device-scmi/src/vhu_scmi.rs +++ b/vhost-device-scmi/src/vhu_scmi.rs @@ -158,7 +158,7 @@ impl VuScmiBackend { let eventfd_list = self.scmi_handler.get_device_eventfd_list(); for (device_notify_fd, device_event) in eventfd_list { handlers[0] - .register_listener(device_notify_fd, EventSet::IN, device_event as u64) + .register_listener(device_notify_fd, EventSet::IN, u64::from(device_event)) .unwrap(); } } From e66908fe5daab4d90d80c0a6cbbbfc3759b354b2 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Fri, 1 Aug 2025 21:19:54 +0300 Subject: [PATCH 12/14] scsi: enable workspace-wide lints Signed-off-by: Manos Pitsidianakis --- vhost-device-scsi/Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vhost-device-scsi/Cargo.toml b/vhost-device-scsi/Cargo.toml index c37dcbab..c5caa059 100644 --- a/vhost-device-scsi/Cargo.toml +++ b/vhost-device-scsi/Cargo.toml @@ -32,3 +32,6 @@ vmm-sys-util = "0.14" assert_matches = "1.5" tempfile = "3.20.0" virtio-queue = { version = "0.16", features = ["test-utils"] } + +[lints] +workspace = true From 8843d5a551205a63a1336f0616efae777c9cbbc1 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Fri, 1 Aug 2025 21:20:07 +0300 Subject: [PATCH 13/14] sound: enable workspace-wide lints Signed-off-by: Manos Pitsidianakis --- vhost-device-sound/Cargo.toml | 3 +++ vhost-device-sound/src/stream.rs | 13 ++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/vhost-device-sound/Cargo.toml b/vhost-device-sound/Cargo.toml index 0355ca7e..035aaebb 100644 --- a/vhost-device-sound/Cargo.toml +++ b/vhost-device-sound/Cargo.toml @@ -42,3 +42,6 @@ vm-memory = { version = "0.16.1", features = ["backend-mmap", "backend-atomic"] [target.'cfg(target_env = "gnu")'.dev-dependencies] rand = { version = "0.9.2" } rusty-fork = { version = "0.3.0" } + +[lints] +workspace = true diff --git a/vhost-device-sound/src/stream.rs b/vhost-device-sound/src/stream.rs index f6259e94..36f3b841 100644 --- a/vhost-device-sound/src/stream.rs +++ b/vhost-device-sound/src/stream.rs @@ -156,21 +156,20 @@ impl PCMState { impl std::fmt::Display for PCMState { fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result { - use PCMState::*; - match *self { - SetParameters => { + match self { + Self::SetParameters => { write!(fmt, "VIRTIO_SND_R_PCM_SET_PARAMS") } - Prepare => { + Self::Prepare => { write!(fmt, "VIRTIO_SND_R_PCM_PREPARE") } - Release => { + Self::Release => { write!(fmt, "VIRTIO_SND_R_PCM_RELEASE") } - Start => { + Self::Start => { write!(fmt, "VIRTIO_SND_R_PCM_START") } - Stop => { + Self::Stop => { write!(fmt, "VIRTIO_SND_R_PCM_STOP") } } From bab70cdf001d2b5d78b40aa0f0438163532ac219 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Fri, 1 Aug 2025 21:20:19 +0300 Subject: [PATCH 14/14] spi: enable workspace-wide lints Signed-off-by: Manos Pitsidianakis --- vhost-device-spi/Cargo.toml | 3 +++ vhost-device-spi/src/linux_spi.rs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/vhost-device-spi/Cargo.toml b/vhost-device-spi/Cargo.toml index ad643e29..57a9dd61 100644 --- a/vhost-device-spi/Cargo.toml +++ b/vhost-device-spi/Cargo.toml @@ -33,3 +33,6 @@ bitflags = "2.9.1" assert_matches = "1.5" virtio-queue = { version = "0.16", features = ["test-utils"] } vm-memory = { version = "0.16.1", features = ["backend-mmap", "backend-atomic"] } + +[lints] +workspace = true diff --git a/vhost-device-spi/src/linux_spi.rs b/vhost-device-spi/src/linux_spi.rs index e003f7d4..59525792 100644 --- a/vhost-device-spi/src/linux_spi.rs +++ b/vhost-device-spi/src/linux_spi.rs @@ -58,7 +58,7 @@ pub fn spi_ioc_message(n: u32) -> u64 { if n * 32 < (1 << _IOC_SIZEBITS) { size = n * 32; } - (SPI_IOC_MESSAGE_BASE | (size << _IOC_SIZESHIFT)) as u64 + u64::from(SPI_IOC_MESSAGE_BASE | (size << _IOC_SIZESHIFT)) } bitflags! {