diff --git a/usbsas-cmdexec/src/lib.rs b/usbsas-cmdexec/src/lib.rs index 9a7ff9c0..2ee73c4f 100644 --- a/usbsas-cmdexec/src/lib.rs +++ b/usbsas-cmdexec/src/lib.rs @@ -165,13 +165,13 @@ impl RunningState { fn exec_cmd(&self, binpath: String, args: Vec) -> Result<()> { info!("executing {} {:?}", binpath, args); - if let Ok(cmd) = Command::new(binpath) + match Command::new(binpath) .args(args) .stdout(Stdio::piped()) .stderr(Stdio::piped()) .spawn() { - match cmd.wait_with_output() { + Ok(cmd) => match cmd.wait_with_output() { Ok(output) => { if !output.status.success() { error!("cmd failed"); @@ -183,14 +183,11 @@ impl RunningState { } return Err(Error::Exec("Cmd failed".into())); } + Ok(()) } - Err(err) => { - return Err(Error::Exec(format!("Can't get cmd result: {err}"))); - } - } - Ok(()) - } else { - Err(Error::Exec("Failed to start child cmd".into())) + Err(err) => Err(Error::Exec(format!("Can't get cmd result: {err}"))), + }, + Err(err) => Err(Error::Exec(format!("Failed to start child cmd: {err}"))), } } } diff --git a/usbsas-usbsas/src/main.rs b/usbsas-usbsas/src/main.rs index d38b235f..a6b09c65 100644 --- a/usbsas-usbsas/src/main.rs +++ b/usbsas-usbsas/src/main.rs @@ -2244,7 +2244,7 @@ struct OutFiles { fn main() -> Result<()> { let session_id = match env::var("USBSAS_SESSION_ID") { - Ok(id) => id.to_string(), + Ok(id) => id, Err(_) => { let id = uuid::Uuid::new_v4().simple().to_string(); env::set_var("USBSAS_SESSION_ID", &id);