From 6ea2438425e7238f0dd2482fb6a98e4e74802b73 Mon Sep 17 00:00:00 2001 From: weishu Date: Fri, 12 Apr 2024 10:36:25 +0800 Subject: [PATCH] ksud: Fix clippy --- userspace/ksud/src/boot_patch.rs | 8 +++----- userspace/ksud/src/cli.rs | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/userspace/ksud/src/boot_patch.rs b/userspace/ksud/src/boot_patch.rs index 0b4cd2e0..ac4feee8 100644 --- a/userspace/ksud/src/boot_patch.rs +++ b/userspace/ksud/src/boot_patch.rs @@ -148,12 +148,10 @@ fn dd, Q: AsRef>(ifile: P, ofile: Q) -> Result<()> { } pub fn restore( - image: impl AsRef, + image: Option, magiskboot_path: Option, flash: bool, ) -> Result<()> { - let image = image.as_ref(); - ensure!(image.exists(), "boot image not found"); let workding_dir = tempdir::TempDir::new("KernelSU").with_context(|| "create temp dir failed")?; let magiskboot = find_magiskboot(magiskboot_path, workding_dir.path())?; @@ -196,7 +194,7 @@ pub fn restore( ensure!(status.success(), "magiskboot repack failed"); let new_boot = workding_dir.path().join("new-boot.img"); - if image.exists() { + if image.is_some() { // if image is specified, write to output file let output_dir = std::env::current_dir()?; let now = chrono::Utc::now(); @@ -399,7 +397,7 @@ fn flash_boot(bootdevice: Option, new_boot: PathBuf) -> Result<()> { .arg(&bootdevice) .status()?; ensure!(status.success(), "set boot device rw failed"); - dd(&new_boot, &bootdevice).with_context(|| "flash boot failed")?; + dd(new_boot, &bootdevice).with_context(|| "flash boot failed")?; Ok(()) } diff --git a/userspace/ksud/src/cli.rs b/userspace/ksud/src/cli.rs index fce70242..117a2d87 100644 --- a/userspace/ksud/src/cli.rs +++ b/userspace/ksud/src/cli.rs @@ -371,7 +371,7 @@ pub fn run() -> Result<()> { boot, magiskboot, flash, - } => crate::boot_patch::restore(boot.unwrap(), magiskboot, flash), + } => crate::boot_patch::restore(boot, magiskboot, flash), }; if let Err(e) = &result {