diff --git a/vhost-device-input/Cargo.toml b/vhost-device-input/Cargo.toml index 69ab521..a3d22cf 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 5f37ea3..4456b65 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);