You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Apply clippy fix
This commit is contained in:
+18
-19
@@ -269,13 +269,13 @@ impl Cpio {
|
||||
}
|
||||
|
||||
fn load_from_file(path: &Utf8CStr) -> LoggedResult<Self> {
|
||||
eprintln!("Loading cpio: [{}]", path);
|
||||
eprintln!("Loading cpio: [{path}]");
|
||||
let file = MappedFile::open(path)?;
|
||||
Self::load_from_data(file.as_ref())
|
||||
}
|
||||
|
||||
fn dump(&self, path: &str) -> LoggedResult<()> {
|
||||
eprintln!("Dumping cpio: [{}]", path);
|
||||
eprintln!("Dumping cpio: [{path}]");
|
||||
let mut file = File::create(path)?;
|
||||
let mut pos = 0usize;
|
||||
let mut inode = 300000i64;
|
||||
@@ -320,13 +320,13 @@ impl Cpio {
|
||||
fn rm(&mut self, path: &str, recursive: bool) {
|
||||
let path = norm_path(path);
|
||||
if self.entries.remove(&path).is_some() {
|
||||
eprintln!("Removed entry [{}]", path);
|
||||
eprintln!("Removed entry [{path}]");
|
||||
}
|
||||
if recursive {
|
||||
let path = path + "/";
|
||||
self.entries.retain(|k, _| {
|
||||
if k.starts_with(&path) {
|
||||
eprintln!("Removed entry [{}]", k);
|
||||
eprintln!("Removed entry [{k}]");
|
||||
false
|
||||
} else {
|
||||
true
|
||||
@@ -340,7 +340,7 @@ impl Cpio {
|
||||
.entries
|
||||
.get(path)
|
||||
.ok_or_else(|| log_err!("No such file"))?;
|
||||
eprintln!("Extracting entry [{}] to [{}]", path, out);
|
||||
eprintln!("Extracting entry [{path}] to [{out}]");
|
||||
|
||||
let out = Utf8CStr::from_string(out);
|
||||
|
||||
@@ -435,7 +435,7 @@ impl Cpio {
|
||||
data: content,
|
||||
}),
|
||||
);
|
||||
eprintln!("Add file [{}] ({:04o})", path, mode);
|
||||
eprintln!("Add file [{path}] ({mode:04o})");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -451,7 +451,7 @@ impl Cpio {
|
||||
data: vec![],
|
||||
}),
|
||||
);
|
||||
eprintln!("Create directory [{}] ({:04o})", dir, mode);
|
||||
eprintln!("Create directory [{dir}] ({mode:04o})");
|
||||
}
|
||||
|
||||
fn ln(&mut self, src: &str, dst: &str) {
|
||||
@@ -466,7 +466,7 @@ impl Cpio {
|
||||
data: norm_path(src).as_bytes().to_vec(),
|
||||
}),
|
||||
);
|
||||
eprintln!("Create symlink [{}] -> [{}]", dst, src);
|
||||
eprintln!("Create symlink [{dst}] -> [{src}]");
|
||||
}
|
||||
|
||||
fn mv(&mut self, from: &str, to: &str) -> LoggedResult<()> {
|
||||
@@ -475,7 +475,7 @@ impl Cpio {
|
||||
.remove(&norm_path(from))
|
||||
.ok_or_else(|| log_err!("no such entry {}", from))?;
|
||||
self.entries.insert(norm_path(to), entry);
|
||||
eprintln!("Move [{}] -> [{}]", from, to);
|
||||
eprintln!("Move [{from}] -> [{to}]");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -498,7 +498,7 @@ impl Cpio {
|
||||
if !recursive && !p.is_empty() && p.matches('/').count() > 1 {
|
||||
continue;
|
||||
}
|
||||
println!("{}\t{}", entry, name);
|
||||
println!("{entry}\t{name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -511,8 +511,7 @@ impl Cpio {
|
||||
let keep_verity = check_env("KEEPVERITY");
|
||||
let keep_force_encrypt = check_env("KEEPFORCEENCRYPT");
|
||||
eprintln!(
|
||||
"Patch with flag KEEPVERITY=[{}] KEEPFORCEENCRYPT=[{}]",
|
||||
keep_verity, keep_force_encrypt
|
||||
"Patch with flag KEEPVERITY=[{keep_verity}] KEEPFORCEENCRYPT=[{keep_force_encrypt}]"
|
||||
);
|
||||
self.entries.retain(|name, entry| {
|
||||
let fstab = (!keep_verity || !keep_force_encrypt)
|
||||
@@ -523,7 +522,7 @@ impl Cpio {
|
||||
&& name.starts_with("fstab");
|
||||
if !keep_verity {
|
||||
if fstab {
|
||||
eprintln!("Found fstab file [{}]", name);
|
||||
eprintln!("Found fstab file [{name}]");
|
||||
let len = patch_verity(entry.data.as_mut_slice());
|
||||
if len != entry.data.len() {
|
||||
entry.data.resize(len, 0);
|
||||
@@ -581,7 +580,7 @@ impl Cpio {
|
||||
} else {
|
||||
&name[8..]
|
||||
};
|
||||
eprintln!("Restore [{}] -> [{}]", name, new_name);
|
||||
eprintln!("Restore [{name}] -> [{new_name}]");
|
||||
backups.insert(new_name.to_string(), entry);
|
||||
}
|
||||
});
|
||||
@@ -658,16 +657,16 @@ impl Cpio {
|
||||
match action {
|
||||
Action::Backup(name, mut entry) => {
|
||||
let backup = if !skip_compress && entry.compress() {
|
||||
format!(".backup/{}.xz", name)
|
||||
format!(".backup/{name}.xz")
|
||||
} else {
|
||||
format!(".backup/{}", name)
|
||||
format!(".backup/{name}")
|
||||
};
|
||||
eprintln!("Backup [{}] -> [{}]", name, backup);
|
||||
eprintln!("Backup [{name}] -> [{backup}]");
|
||||
backups.insert(backup, entry);
|
||||
}
|
||||
Action::Record(name) => {
|
||||
eprintln!("Record new entry: [{}] -> [.backup/.rmlist]", name);
|
||||
rm_list.push_str(&format!("{}\0", name));
|
||||
eprintln!("Record new entry: [{name}] -> [.backup/.rmlist]");
|
||||
rm_list.push_str(&format!("{name}\0"));
|
||||
}
|
||||
Action::Noop => {}
|
||||
}
|
||||
|
||||
@@ -131,9 +131,9 @@ fn print_node(node: &FdtNode) {
|
||||
}
|
||||
);
|
||||
} else if size > MAX_PRINT_LEN {
|
||||
println!("[{}]: <bytes>({})", name, size);
|
||||
println!("[{name}]: <bytes>({size})");
|
||||
} else {
|
||||
println!("[{}]: {:02x?}", name, value);
|
||||
println!("[{name}]: {value:02x?}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ fn for_each_fdt<F: FnMut(usize, Fdt) -> LoggedResult<()>>(
|
||||
rw: bool,
|
||||
mut f: F,
|
||||
) -> LoggedResult<()> {
|
||||
eprintln!("Loading dtbs from [{}]", file);
|
||||
eprintln!("Loading dtbs from [{file}]");
|
||||
let file = if rw {
|
||||
MappedFile::open_rw(file)?
|
||||
} else {
|
||||
@@ -173,7 +173,7 @@ fn for_each_fdt<F: FnMut(usize, Fdt) -> LoggedResult<()>>(
|
||||
}
|
||||
let fdt = match Fdt::new(slice) {
|
||||
Err(FdtError::BufferTooSmall) => {
|
||||
eprintln!("dtb.{:04} is truncated", dtb_num);
|
||||
eprintln!("dtb.{dtb_num:04} is truncated");
|
||||
break;
|
||||
}
|
||||
Ok(fdt) => fdt,
|
||||
@@ -198,11 +198,11 @@ fn dtb_print(file: &Utf8CStr, fstab: bool) -> LoggedResult<()> {
|
||||
for_each_fdt(file, false, |n, fdt| {
|
||||
if fstab {
|
||||
if let Some(fstab) = find_fstab(&fdt) {
|
||||
eprintln!("Found fstab in dtb.{:04}", n);
|
||||
eprintln!("Found fstab in dtb.{n:04}");
|
||||
print_node(&fstab);
|
||||
}
|
||||
} else if let Some(mut root) = fdt.find_node("/") {
|
||||
eprintln!("Printing dtb.{:04}", n);
|
||||
eprintln!("Printing dtb.{n:04}");
|
||||
if root.name.is_empty() {
|
||||
root.name = "/";
|
||||
}
|
||||
@@ -248,7 +248,7 @@ fn dtb_patch(file: &Utf8CStr) -> LoggedResult<bool> {
|
||||
&mut *std::mem::transmute::<&[u8], &UnsafeCell<[u8]>>(w).get()
|
||||
};
|
||||
w[..=4].copy_from_slice(b"want");
|
||||
eprintln!("Patch [skip_initramfs] -> [want_initramfs] in dtb.{:04}", n);
|
||||
eprintln!("Patch [skip_initramfs] -> [want_initramfs] in dtb.{n:04}");
|
||||
patched = true;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -45,7 +45,7 @@ fn remove_pattern(buf: &mut [u8], pattern_matcher: unsafe fn(&[u8]) -> Option<us
|
||||
let skipped = buf.get_unchecked(read..(read + len));
|
||||
// SAFETY: all matching patterns are ASCII bytes
|
||||
let skipped = std::str::from_utf8_unchecked(skipped);
|
||||
eprintln!("Remove pattern [{}]", skipped);
|
||||
eprintln!("Remove pattern [{skipped}]");
|
||||
sz -= len;
|
||||
read += len;
|
||||
} else {
|
||||
@@ -114,7 +114,7 @@ pub fn hexpatch(file: &[u8], from: &[u8], to: &[u8]) -> bool {
|
||||
|
||||
let v = map.patch(pattern.as_slice(), patch.as_slice());
|
||||
for off in &v {
|
||||
eprintln!("Patch @ {:#010X} [{}] -> [{}]", off, from, to);
|
||||
eprintln!("Patch @ {off:#010X} [{from}] -> [{to}]");
|
||||
}
|
||||
!v.is_empty()
|
||||
};
|
||||
|
||||
@@ -34,7 +34,7 @@ fn do_extract_boot_from_payload(
|
||||
let mut reader = BufReader::new(if in_path == "-" {
|
||||
unsafe { File::from_raw_fd(0) }
|
||||
} else {
|
||||
File::open(in_path).log_with_msg(|w| write!(w, "Cannot open '{}'", in_path))?
|
||||
File::open(in_path).log_with_msg(|w| write!(w, "Cannot open '{in_path}'"))?
|
||||
});
|
||||
|
||||
let buf = &mut [0u8; 4];
|
||||
@@ -107,7 +107,7 @@ fn do_extract_boot_from_payload(
|
||||
};
|
||||
|
||||
let mut out_file =
|
||||
File::create(out_path).log_with_msg(|w| write!(w, "Cannot write to '{}'", out_path))?;
|
||||
File::create(out_path).log_with_msg(|w| write!(w, "Cannot write to '{out_path}'"))?;
|
||||
|
||||
// Skip the manifest signature
|
||||
reader.skip(manifest_sig_len as usize)?;
|
||||
|
||||
Reference in New Issue
Block a user