inputd: minor clippy fixes

Signed-off-by: Anhad Singh <andypython@protonmail.com>
This commit is contained in:
Anhad Singh
2023-07-25 16:36:46 +10:00
parent 820b8370ae
commit ed995306bd
2 changed files with 11 additions and 7 deletions
+4 -4
View File
@@ -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<usize, Error> {
Ok(self.0.read(&mut [])?)
self.0.read(&mut [])
}
pub fn activate(&mut self, vt: usize, mode: VtMode) -> Result<usize, Error> {
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<Cmd> {
let cmd = unsafe { &*buffer.as_ptr().offset(1).cast::<VtActivate>() };
Some(Cmd::Activate {
vt: cmd.vt,
mode: VtMode::from(cmd.mode),
mode: cmd.mode,
})
}
+7 -3
View File
@@ -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);