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
8d7c7c3dfb
commit
b750c89c87
@ -1,13 +1,16 @@
|
|||||||
use crate::{check_env, patch::patch_verity};
|
use std::{cell::UnsafeCell, process::exit};
|
||||||
|
|
||||||
use argh::FromArgs;
|
use argh::FromArgs;
|
||||||
use base::{
|
|
||||||
libc::c_char, log_err, map_args, EarlyExitExt, LoggedResult, MappedFile, ResultExt, Utf8CStr,
|
|
||||||
};
|
|
||||||
use fdt::{
|
use fdt::{
|
||||||
node::{FdtNode, NodeProperty},
|
node::{FdtNode, NodeProperty},
|
||||||
Fdt,
|
Fdt,
|
||||||
};
|
};
|
||||||
use std::{cell::UnsafeCell, fmt::Write, process::exit};
|
|
||||||
|
use base::{
|
||||||
|
libc::c_char, log_err, map_args, EarlyExitExt, LoggedResult, MappedFile, ResultExt, Utf8CStr,
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::{check_env, patch::patch_verity};
|
||||||
|
|
||||||
#[derive(FromArgs)]
|
#[derive(FromArgs)]
|
||||||
struct DtbCli {
|
struct DtbCli {
|
||||||
@ -62,7 +65,7 @@ Supported actions:
|
|||||||
const MAX_PRINT_LEN: usize = 32;
|
const MAX_PRINT_LEN: usize = 32;
|
||||||
|
|
||||||
fn print_node(node: &FdtNode) {
|
fn print_node(node: &FdtNode) {
|
||||||
fn pretty_node(depth_set: &Vec<bool>) {
|
fn pretty_node(depth_set: &[bool]) {
|
||||||
let mut depth_set = depth_set.iter().peekable();
|
let mut depth_set = depth_set.iter().peekable();
|
||||||
while let Some(depth) = depth_set.next() {
|
while let Some(depth) = depth_set.next() {
|
||||||
let last = depth_set.peek().is_none();
|
let last = depth_set.peek().is_none();
|
||||||
@ -72,17 +75,15 @@ fn print_node(node: &FdtNode) {
|
|||||||
} else {
|
} else {
|
||||||
print!("│ ");
|
print!("│ ");
|
||||||
}
|
}
|
||||||
} else {
|
} else if last {
|
||||||
if last {
|
|
||||||
print!("└── ");
|
print!("└── ");
|
||||||
} else {
|
} else {
|
||||||
print!(" ");
|
print!(" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fn pretty_prop(depth_set: &Vec<bool>) {
|
fn pretty_prop(depth_set: &[bool]) {
|
||||||
let mut depth_set = depth_set.iter().peekable();
|
let mut depth_set = depth_set.iter().peekable();
|
||||||
while let Some(depth) = depth_set.next() {
|
while let Some(depth) = depth_set.next() {
|
||||||
let last = depth_set.peek().is_none();
|
let last = depth_set.peek().is_none();
|
||||||
@ -92,15 +93,13 @@ fn print_node(node: &FdtNode) {
|
|||||||
} else {
|
} else {
|
||||||
print!("│ ");
|
print!("│ ");
|
||||||
}
|
}
|
||||||
} else {
|
} else if last {
|
||||||
if last {
|
|
||||||
print!("└─ ");
|
print!("└─ ");
|
||||||
} else {
|
} else {
|
||||||
print!(" ");
|
print!(" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fn do_print_node(node: &FdtNode, depth_set: &mut Vec<bool>) {
|
fn do_print_node(node: &FdtNode, depth_set: &mut Vec<bool>) {
|
||||||
pretty_node(depth_set);
|
pretty_node(depth_set);
|
||||||
@ -130,14 +129,12 @@ fn print_node(node: &FdtNode) {
|
|||||||
unsafe { Utf8CStr::from_bytes_unchecked(value) }
|
unsafe { Utf8CStr::from_bytes_unchecked(value) }
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else if size > MAX_PRINT_LEN {
|
||||||
if size > MAX_PRINT_LEN {
|
|
||||||
println!("[{}]: <bytes>({})", name, size);
|
println!("[{}]: <bytes>({})", name, size);
|
||||||
} else {
|
} else {
|
||||||
println!("[{}]: {:02x?}", name, value);
|
println!("[{}]: {:02x?}", name, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
while let Some(child) = children.next() {
|
while let Some(child) = children.next() {
|
||||||
if depth_set[depth] && children.peek().is_none() {
|
if depth_set[depth] && children.peek().is_none() {
|
||||||
@ -191,12 +188,7 @@ fn for_each_fdt<F: FnMut(usize, Fdt) -> LoggedResult<()>>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn find_fstab<'b, 'a: 'b>(fdt: &'b Fdt<'a>) -> Option<FdtNode<'b, 'a>> {
|
fn find_fstab<'b, 'a: 'b>(fdt: &'b Fdt<'a>) -> Option<FdtNode<'b, 'a>> {
|
||||||
for node in fdt.all_nodes() {
|
fdt.all_nodes().find(|node| node.name == "fstab")
|
||||||
if node.name == "fstab" {
|
|
||||||
return Some(node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dtb_print(file: &Utf8CStr, fstab: bool) -> LoggedResult<()> {
|
fn dtb_print(file: &Utf8CStr, fstab: bool) -> LoggedResult<()> {
|
||||||
@ -206,15 +198,13 @@ fn dtb_print(file: &Utf8CStr, fstab: bool) -> LoggedResult<()> {
|
|||||||
eprintln!("Found fstab in dtb.{:04}", n);
|
eprintln!("Found fstab in dtb.{:04}", n);
|
||||||
print_node(&fstab);
|
print_node(&fstab);
|
||||||
}
|
}
|
||||||
} else {
|
} else if let Some(mut root) = fdt.find_node("/") {
|
||||||
if let Some(mut root) = fdt.find_node("/") {
|
|
||||||
eprintln!("Printing dtb.{:04}", n);
|
eprintln!("Printing dtb.{:04}", n);
|
||||||
if root.name.is_empty() {
|
if root.name.is_empty() {
|
||||||
root.name = "/";
|
root.name = "/";
|
||||||
}
|
}
|
||||||
print_node(&root);
|
print_node(&root);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user