From c6c1a17ae66ee5ad163c22a5787ca72243f85b4d Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Mon, 3 Mar 2025 02:15:06 -0800 Subject: [PATCH] Address several clippy warnings --- native/src/boot/patch.rs | 2 +- native/src/core/su/daemon.rs | 9 ++++----- native/src/init/getinfo.rs | 28 +++++++++++++++++++--------- native/src/init/twostage.rs | 2 ++ 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/native/src/boot/patch.rs b/native/src/boot/patch.rs index 0740bb63a..15968a5d4 100644 --- a/native/src/boot/patch.rs +++ b/native/src/boot/patch.rs @@ -95,7 +95,7 @@ fn hex2byte(hex: &[u8]) -> Vec { let low = bytes[1].to_ascii_uppercase() - b'0'; let h = if high > 9 { high - 7 } else { high }; let l = if low > 9 { low - 7 } else { low }; - v.push(h << 4 | l); + v.push((h << 4) | l); } v } diff --git a/native/src/core/su/daemon.rs b/native/src/core/su/daemon.rs index 5a4378126..92a322e6e 100644 --- a/native/src/core/su/daemon.rs +++ b/native/src/core/su/daemon.rs @@ -8,7 +8,7 @@ use crate::su::db::RootSettings; use crate::UCred; use base::{debug, error, exit_on_error, libc, warn, LoggedResult, ResultExt, WriteExt}; 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::sync::{Arc, Mutex}; use std::time::{Duration, Instant}; @@ -113,15 +113,14 @@ impl AccessInfo { impl MagiskD { pub fn su_daemon_handler(&self, client: i32, cred: &UCred) { - let mut client = unsafe { UnixStream::from_raw_fd(client) }; let cred = cred.0; debug!( "su: request from uid=[{}], pid=[{}], client=[{}]", - cred.uid, - cred.pid, - client.as_raw_fd() + cred.uid, cred.pid, client ); + let mut client = unsafe { UnixStream::from_raw_fd(client) }; + let mut req = match client.read_decodable::().log() { Ok(req) => req, Err(_) => { diff --git a/native/src/init/getinfo.rs b/native/src/init/getinfo.rs index a19c73c7b..e2c7daea0 100644 --- a/native/src/init/getinfo.rs +++ b/native/src/init/getinfo.rs @@ -1,23 +1,33 @@ use crate::ffi::{backup_init, BootConfig, MagiskInit}; -use base::{debug, path, BytesExt, MappedFile}; -use std::ffi::CStr; +use base::{path, BytesExt, MappedFile}; impl BootConfig { + #[allow(unused_imports, unused_unsafe)] pub(crate) fn print(&self) { + use base::{debug, Utf8CStr}; debug!("skip_initramfs=[{}]", self.skip_initramfs); debug!("force_normal_boot=[{}]", self.force_normal_boot); debug!("rootwait=[{}]", self.rootwait); unsafe { - debug!("slot=[{:?}]", CStr::from_ptr(self.slot.as_ptr())); - debug!("dt_dir=[{:?}]", CStr::from_ptr(self.dt_dir.as_ptr())); debug!( - "fstab_suffix=[{:?}]", - CStr::from_ptr(self.fstab_suffix.as_ptr()) + "slot=[{}]", + Utf8CStr::from_ptr_unchecked(self.slot.as_ptr()) ); - debug!("hardware=[{:?}]", CStr::from_ptr(self.hardware.as_ptr())); debug!( - "hardware.platform=[{:?}]", - CStr::from_ptr(self.hardware_plat.as_ptr()) + "dt_dir=[{}]", + 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); diff --git a/native/src/init/twostage.rs b/native/src/init/twostage.rs index f34a9edf5..a8482d976 100644 --- a/native/src/init/twostage.rs +++ b/native/src/init/twostage.rs @@ -81,6 +81,7 @@ impl MagiskInit { // Redirect original init to magiskinit let v = map.patch(from.as_bytes(), to.as_bytes()); + #[allow(unused_variables)] for off in &v { debug!("Patch @ {:#010X} [{}] -> [{}]", off, from, to); } @@ -100,6 +101,7 @@ impl MagiskInit { // Redirect original init to magiskinit let v = map.patch(from.as_bytes(), to.as_bytes()); + #[allow(unused_variables)] for off in &v { debug!("Patch @ {:#010X} [{}] -> [{}]", off, from, to); }