From 967614c73398d889a3da13db59a2ce0de9168b12 Mon Sep 17 00:00:00 2001 From: alexkar598 <25136265+alexkar598@users.noreply.github.com> Date: Sun, 23 Jun 2024 00:43:06 -0400 Subject: [PATCH] Makes the latest clippy lints happy --- src/main.rs | 8 ++++---- src/process.rs | 14 +++++++------- src/signal.rs | 7 ++----- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/main.rs b/src/main.rs index 96cb6c2..7da2cb8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -53,7 +53,7 @@ fn main() { if let Err(e) = port.read_exact(&mut serial_char_buf) { match e.kind() { io::ErrorKind::TimedOut | io::ErrorKind::UnexpectedEof => continue, - _ => panic!("IO error when reading character: {}", e), + _ => panic!("IO error when reading character: {e}"), } } @@ -82,7 +82,7 @@ fn main() { } // If the port could not be opened, print an error and exit Err(e) => { - eprintln!("Failed to open serial connection. Error: {}", e); + eprintln!("Failed to open serial connection. Error: {e}"); std::process::exit(1); } } @@ -109,8 +109,8 @@ fn process_cmds( ["signal", pid, signal] => signal::send(pid, signal), ["poll"] => Ok(poll::send_poll_data(poll_data)), _ => { - eprintln!("Unknown cmd: {}", cmd); - Err(format!("Unknown cmd: {}", cmd)) + eprintln!("Unknown cmd: {cmd}"); + Err(format!("Unknown cmd: {cmd}")) } } } diff --git a/src/process.rs b/src/process.rs index 042f776..e2499d1 100644 --- a/src/process.rs +++ b/src/process.rs @@ -29,20 +29,20 @@ pub fn process( let process = match decode(b_process) { Ok(dec_vec) if dec_vec.is_empty() => String::new(), Ok(dec_vec) => String::from_utf8(dec_vec).expect("Invalid UTF8 for exec path"), - Err(e) => return Err(format!("Error decoding exec path: {}", e)), + Err(e) => return Err(format!("Error decoding exec path: {e}")), }; let raw_args = match decode(b_args) { Ok(dec_vec) if dec_vec.is_empty() => String::new(), Ok(dec_vec) => String::from_utf8(dec_vec).expect("Invalid UTF8 for exec args"), - Err(e) => return Err(format!("Error decoding exec args: {}", e)), + Err(e) => return Err(format!("Error decoding exec args: {e}")), }; let args = raw_args.split('\0').collect::>(); let raw_env_vars = match decode(b_env_vars) { Ok(dec_vec) if dec_vec.is_empty() => String::new(), Ok(dec_vec) => String::from_utf8(dec_vec).expect("Invalid UTF8 for exec env args"), - Err(e) => return Err(format!("Error decoding exec env vars: {}", e)), + Err(e) => return Err(format!("Error decoding exec env vars: {e}")), }; // Handle environment vars parsing into tuples @@ -102,7 +102,7 @@ pub fn process( .stderr(Redirection::Pipe) .popen() { - Err(e) => return Err(format!("Failed to create process: {}", e)), + Err(e) => return Err(format!("Failed to create process: {e}")), Ok(proc) => proc, }; @@ -126,7 +126,7 @@ pub fn process( data.1.map(|dat| String::from_utf8_lossy(&dat).into_owned()), ) } - Err(e) => panic!("Error while reading comms: {}", e), + Err(e) => panic!("Error while reading comms: {e}"), } }; push_possible_output(comm_data, pid, &poll_data); @@ -140,7 +140,7 @@ pub fn process( ExitStatus::Exited(code) => code, ExitStatus::Undetermined => 256, ExitStatus::Signaled(signal) => 256 + u32::from(signal), - ExitStatus::Other(what) => panic!("Unknown ExitStatus: {}", what), + ExitStatus::Other(what) => panic!("Unknown ExitStatus: {what}"), }; poll_data.lock().unwrap().push(PollData { typ: PollType::PidExit, @@ -153,7 +153,7 @@ pub fn process( } }); - Ok(format!("{}\n", pid)) + Ok(format!("{pid}\n")) } fn push_possible_output( diff --git a/src/signal.rs b/src/signal.rs index 98d9fc7..83f1d06 100644 --- a/src/signal.rs +++ b/src/signal.rs @@ -13,11 +13,8 @@ pub fn send(pid: &&str, signal: &&str) -> Result { nix::unistd::Pid::from_raw(pid.parse::().expect("Malformed pid")), sig, ) { - Ok(_) => Ok(String::new()), - Err(e) => Err(format!( - "Error sending signal {} to pid {}: {}", - sig, pid, e - )), + Ok(()) => Ok(String::new()), + Err(e) => Err(format!("Error sending signal {sig} to pid {pid}: {e}")), } }