mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-22 16:07:39 +00:00
Address clippy warnings
This commit is contained in:
parent
24b1c607f3
commit
dc26ad7125
@ -1,4 +1,3 @@
|
|||||||
use argh::{EarlyExit, FromArgs};
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
use std::fmt::{Display, Formatter};
|
use std::fmt::{Display, Formatter};
|
||||||
@ -13,6 +12,7 @@ use std::slice;
|
|||||||
use anyhow::{anyhow, Context};
|
use anyhow::{anyhow, Context};
|
||||||
use size::{Base, Size, Style};
|
use size::{Base, Size, Style};
|
||||||
|
|
||||||
|
use argh::{EarlyExit, FromArgs};
|
||||||
use base::libc::{
|
use base::libc::{
|
||||||
c_char, dev_t, gid_t, major, makedev, minor, mknod, mode_t, uid_t, S_IFBLK, S_IFCHR, S_IFDIR,
|
c_char, dev_t, gid_t, major, makedev, minor, mknod, mode_t, uid_t, S_IFBLK, S_IFCHR, S_IFDIR,
|
||||||
S_IFLNK, S_IFMT, S_IFREG, S_IRGRP, S_IROTH, S_IRUSR, S_IWGRP, S_IWOTH, S_IWUSR, S_IXGRP,
|
S_IFLNK, S_IFMT, S_IFREG, S_IRGRP, S_IROTH, S_IRUSR, S_IWGRP, S_IWOTH, S_IWUSR, S_IXGRP,
|
||||||
@ -308,7 +308,7 @@ impl Cpio {
|
|||||||
|
|
||||||
pub(crate) fn rm(&mut self, path: &str, recursive: bool) {
|
pub(crate) fn rm(&mut self, path: &str, recursive: bool) {
|
||||||
let path = norm_path(path);
|
let path = norm_path(path);
|
||||||
if let Some(_) = self.entries.remove(&path) {
|
if self.entries.remove(&path).is_some() {
|
||||||
eprintln!("Removed entry [{}]", path);
|
eprintln!("Removed entry [{}]", path);
|
||||||
}
|
}
|
||||||
if recursive {
|
if recursive {
|
||||||
@ -462,14 +462,11 @@ impl Cpio {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn ls(&self, path: &str, recursive: bool) {
|
fn ls(&self, path: &str, recursive: bool) {
|
||||||
let path = match norm_path(path) {
|
let path = norm_path(path);
|
||||||
path => {
|
let path = if path.is_empty() {
|
||||||
if path.is_empty() {
|
path
|
||||||
path
|
} else {
|
||||||
} else {
|
"/".to_string() + path.as_str()
|
||||||
"/".to_string() + path.as_str()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
for (name, entry) in &self.entries {
|
for (name, entry) in &self.entries {
|
||||||
let p = "/".to_string() + name.as_str();
|
let p = "/".to_string() + name.as_str();
|
||||||
@ -547,7 +544,7 @@ pub fn cpio_commands(argc: i32, argv: *const *const c_char) -> bool {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let mut cli = match CpioCli::from_args(
|
let mut cli = match CpioCli::from_args(
|
||||||
&["magiskboot", "cpio", &*file],
|
&["magiskboot", "cpio", file],
|
||||||
cmd.split(' ')
|
cmd.split(' ')
|
||||||
.filter(|x| !x.is_empty())
|
.filter(|x| !x.is_empty())
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
@ -582,7 +579,7 @@ pub fn cpio_commands(argc: i32, argv: *const *const c_char) -> bool {
|
|||||||
CpioCommands::Link(Link { src, dst }) => cpio.ln(src, dst),
|
CpioCommands::Link(Link { src, dst }) => cpio.ln(src, dst),
|
||||||
CpioCommands::Add(Add { mode, path, file }) => cpio.add(mode, path, file)?,
|
CpioCommands::Add(Add { mode, path, file }) => cpio.add(mode, path, file)?,
|
||||||
CpioCommands::Extract(Extract { paths }) => {
|
CpioCommands::Extract(Extract { paths }) => {
|
||||||
if paths.len() != 0 && paths.len() != 2 {
|
if !paths.is_empty() && paths.len() != 2 {
|
||||||
return Err(anyhow!("invalid arguments"));
|
return Err(anyhow!("invalid arguments"));
|
||||||
}
|
}
|
||||||
cpio.extract(
|
cpio.extract(
|
||||||
|
@ -93,7 +93,7 @@ fn do_extract_boot_from_payload(
|
|||||||
Some(name) => manifest
|
Some(name) => manifest
|
||||||
.partitions
|
.partitions
|
||||||
.iter()
|
.iter()
|
||||||
.find(|p| p.partition_name.as_str() == &*name)
|
.find(|p| p.partition_name.as_str() == name)
|
||||||
.ok_or(anyhow!("partition '{name}' not found"))?,
|
.ok_or(anyhow!("partition '{name}' not found"))?,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user