Address several clippy warnings

This commit is contained in:
topjohnwu 2025-03-03 02:15:06 -08:00
parent 2b47d47215
commit c6c1a17ae6
4 changed files with 26 additions and 15 deletions

View File

@ -95,7 +95,7 @@ fn hex2byte(hex: &[u8]) -> Vec<u8> {
let low = bytes[1].to_ascii_uppercase() - b'0'; let low = bytes[1].to_ascii_uppercase() - b'0';
let h = if high > 9 { high - 7 } else { high }; let h = if high > 9 { high - 7 } else { high };
let l = if low > 9 { low - 7 } else { low }; let l = if low > 9 { low - 7 } else { low };
v.push(h << 4 | l); v.push((h << 4) | l);
} }
v v
} }

View File

@ -8,7 +8,7 @@ use crate::su::db::RootSettings;
use crate::UCred; use crate::UCred;
use base::{debug, error, exit_on_error, libc, warn, LoggedResult, ResultExt, WriteExt}; use base::{debug, error, exit_on_error, libc, warn, LoggedResult, ResultExt, WriteExt};
use std::fs::File; use std::fs::File;
use std::os::fd::{AsRawFd, FromRawFd, IntoRawFd}; use std::os::fd::{FromRawFd, IntoRawFd};
use std::os::unix::net::UnixStream; use std::os::unix::net::UnixStream;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
@ -113,15 +113,14 @@ impl AccessInfo {
impl MagiskD { impl MagiskD {
pub fn su_daemon_handler(&self, client: i32, cred: &UCred) { pub fn su_daemon_handler(&self, client: i32, cred: &UCred) {
let mut client = unsafe { UnixStream::from_raw_fd(client) };
let cred = cred.0; let cred = cred.0;
debug!( debug!(
"su: request from uid=[{}], pid=[{}], client=[{}]", "su: request from uid=[{}], pid=[{}], client=[{}]",
cred.uid, cred.uid, cred.pid, client
cred.pid,
client.as_raw_fd()
); );
let mut client = unsafe { UnixStream::from_raw_fd(client) };
let mut req = match client.read_decodable::<SuRequest>().log() { let mut req = match client.read_decodable::<SuRequest>().log() {
Ok(req) => req, Ok(req) => req,
Err(_) => { Err(_) => {

View File

@ -1,23 +1,33 @@
use crate::ffi::{backup_init, BootConfig, MagiskInit}; use crate::ffi::{backup_init, BootConfig, MagiskInit};
use base::{debug, path, BytesExt, MappedFile}; use base::{path, BytesExt, MappedFile};
use std::ffi::CStr;
impl BootConfig { impl BootConfig {
#[allow(unused_imports, unused_unsafe)]
pub(crate) fn print(&self) { pub(crate) fn print(&self) {
use base::{debug, Utf8CStr};
debug!("skip_initramfs=[{}]", self.skip_initramfs); debug!("skip_initramfs=[{}]", self.skip_initramfs);
debug!("force_normal_boot=[{}]", self.force_normal_boot); debug!("force_normal_boot=[{}]", self.force_normal_boot);
debug!("rootwait=[{}]", self.rootwait); debug!("rootwait=[{}]", self.rootwait);
unsafe { unsafe {
debug!("slot=[{:?}]", CStr::from_ptr(self.slot.as_ptr()));
debug!("dt_dir=[{:?}]", CStr::from_ptr(self.dt_dir.as_ptr()));
debug!( debug!(
"fstab_suffix=[{:?}]", "slot=[{}]",
CStr::from_ptr(self.fstab_suffix.as_ptr()) Utf8CStr::from_ptr_unchecked(self.slot.as_ptr())
); );
debug!("hardware=[{:?}]", CStr::from_ptr(self.hardware.as_ptr()));
debug!( debug!(
"hardware.platform=[{:?}]", "dt_dir=[{}]",
CStr::from_ptr(self.hardware_plat.as_ptr()) Utf8CStr::from_ptr_unchecked(self.dt_dir.as_ptr())
);
debug!(
"fstab_suffix=[{}]",
Utf8CStr::from_ptr_unchecked(self.fstab_suffix.as_ptr())
);
debug!(
"hardware=[{}]",
Utf8CStr::from_ptr_unchecked(self.hardware.as_ptr())
);
debug!(
"hardware.platform=[{}]",
Utf8CStr::from_ptr_unchecked(self.hardware_plat.as_ptr())
); );
} }
debug!("emulator=[{}]", self.emulator); debug!("emulator=[{}]", self.emulator);

View File

@ -81,6 +81,7 @@ impl MagiskInit {
// Redirect original init to magiskinit // Redirect original init to magiskinit
let v = map.patch(from.as_bytes(), to.as_bytes()); let v = map.patch(from.as_bytes(), to.as_bytes());
#[allow(unused_variables)]
for off in &v { for off in &v {
debug!("Patch @ {:#010X} [{}] -> [{}]", off, from, to); debug!("Patch @ {:#010X} [{}] -> [{}]", off, from, to);
} }
@ -100,6 +101,7 @@ impl MagiskInit {
// Redirect original init to magiskinit // Redirect original init to magiskinit
let v = map.patch(from.as_bytes(), to.as_bytes()); let v = map.patch(from.as_bytes(), to.as_bytes());
#[allow(unused_variables)]
for off in &v { for off in &v {
debug!("Patch @ {:#010X} [{}] -> [{}]", off, from, to); debug!("Patch @ {:#010X} [{}] -> [{}]", off, from, to);
} }