From ed995306bd051fc8a28331deff7dee18c7f31c42 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Tue, 25 Jul 2023 16:36:46 +1000 Subject: [PATCH] inputd: minor clippy fixes Signed-off-by: Anhad Singh --- inputd/src/lib.rs | 8 ++++---- inputd/src/main.rs | 10 +++++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/inputd/src/lib.rs b/inputd/src/lib.rs index c8f9e7e532..a3d1020678 100644 --- a/inputd/src/lib.rs +++ b/inputd/src/lib.rs @@ -15,7 +15,7 @@ pub enum VtMode { Default = 2, } -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Clone)] #[repr(C)] pub struct VtActivate { pub vt: usize, @@ -33,12 +33,12 @@ impl Handle { // The return value is the display identifier. It will be used to uniquely // identify the display on activation events. pub fn register(&mut self) -> Result { - Ok(self.0.read(&mut [])?) + self.0.read(&mut []) } pub fn activate(&mut self, vt: usize, mode: VtMode) -> Result { let cmd = VtActivate { vt, mode }; - Ok(self.0.write(unsafe { any_as_u8_slice(&cmd) })?) + self.0.write(unsafe { any_as_u8_slice(&cmd) }) } } @@ -141,7 +141,7 @@ pub fn parse_command(buffer: &[u8]) -> Option { let cmd = unsafe { &*buffer.as_ptr().offset(1).cast::() }; Some(Cmd::Activate { vt: cmd.vt, - mode: VtMode::from(cmd.mode), + mode: cmd.mode, }) } diff --git a/inputd/src/main.rs b/inputd/src/main.rs index f2d6f1fd0f..2ca582eba6 100644 --- a/inputd/src/main.rs +++ b/inputd/src/main.rs @@ -216,7 +216,7 @@ impl SchemeMut for InputScheme { ) }; - for event in events.iter() { + 'out: for event in events.iter() { let mut new_active_opt = None; match event.to_option() { EventOption::Key(key_event) => match key_event.scancode { @@ -264,6 +264,10 @@ impl SchemeMut for InputScheme { } if let Some(new_active) = new_active_opt { + if new_active == self.active_vt.as_ref().unwrap().index { + continue 'out; + } + if let Some(new_active) = self.vts.get(&new_active).cloned() { { let active_vt = self.active_vt.as_ref().unwrap(); @@ -372,7 +376,7 @@ fn deamon(deamon: redox_daemon::Daemon) -> anyhow::Result<()> { &mut vt_inner.handle_file, Cmd::Activate { vt: vt.index, - mode: VtMode::from(cmd.mode), + mode: cmd.mode, }, ) { log::error!("inputd: failed to activate VT #{}: {err}", vt.index) @@ -501,7 +505,7 @@ pub fn main() { "vesa" } else { // TODO: What should we do when there are multiple display devices? - device[0].split("/").nth(2).unwrap() + device[0].split('/').nth(2).unwrap() }; dbg!(&device);