Fix clippy warnings across native codebase

Address clippy warnings including collapsible match statements in
bootstages, daemon, su daemon, and db modules, as well as iterator
loops in files.rs.

Assisted-by: Gemini 3.6 Flash
This commit is contained in:
topjohnwu
2026-07-31 22:57:41 -07:00
committed by John Wu
parent 05099cce89
commit d04635478a
5 changed files with 30 additions and 53 deletions
+2 -5
View File
@@ -422,16 +422,13 @@ impl Utf8CStr {
}
let mut path = cstr::buf::default();
let mut components = self.split('/').filter(|s| !s.is_empty());
let components = self.split('/').filter(|s| !s.is_empty());
if self.starts_with('/') {
path.append_path("/");
}
loop {
let Some(s) = components.next() else {
break;
};
for s in components {
path.append_path(s);
path.mkdir(mode)?;
}
+6 -6
View File
@@ -195,13 +195,13 @@ impl MagiskD {
let mut state = self.boot_stage_lock.lock();
match code {
RequestCode::POST_FS_DATA => {
if check_data() && !state.contains(BootState::PostFsDataDone) {
if self.post_fs_data() {
state.insert(BootState::SafeMode);
}
state.insert(BootState::PostFsDataDone);
RequestCode::POST_FS_DATA
if check_data() && !state.contains(BootState::PostFsDataDone) =>
{
if self.post_fs_data() {
state.insert(BootState::SafeMode);
}
state.insert(BootState::PostFsDataDone);
}
RequestCode::LATE_START => {
drop(client);
+13 -17
View File
@@ -226,25 +226,21 @@ impl MagiskD {
| RequestCode::ZYGOTE_RESTART
| RequestCode::SQLITE_CMD
| RequestCode::DENYLIST
| RequestCode::STOP_DAEMON => {
if !is_root {
client.write_pod(&RespondCode::ROOT_REQUIRED.repr).log_ok();
return;
}
| RequestCode::STOP_DAEMON
if !is_root =>
{
client.write_pod(&RespondCode::ROOT_REQUIRED.repr).log_ok();
return;
}
RequestCode::REMOVE_MODULES => {
if !is_root && !is_shell {
// Only allow root and ADB shell to remove modules
client.write_pod(&RespondCode::ACCESS_DENIED.repr).log_ok();
return;
}
RequestCode::REMOVE_MODULES if !is_root && !is_shell => {
// Only allow root and ADB shell to remove modules
client.write_pod(&RespondCode::ACCESS_DENIED.repr).log_ok();
return;
}
RequestCode::ZYGISK => {
if !is_zygote {
// Invalid client context
client.write_pod(&RespondCode::ACCESS_DENIED.repr).log_ok();
return;
}
RequestCode::ZYGISK if !is_zygote => {
// Invalid client context
client.write_pod(&RespondCode::ACCESS_DENIED.repr).log_ok();
return;
}
_ => {}
}
+6 -10
View File
@@ -252,17 +252,13 @@ impl MagiskD {
warn!("Root access is disabled!");
return Ok(Arc::new(SuInfo::deny(uid)));
}
RootAccess::AdbOnly => {
if uid != AID_SHELL {
warn!("Root access limited to ADB only!");
return Ok(Arc::new(SuInfo::deny(uid)));
}
RootAccess::AdbOnly if uid != AID_SHELL => {
warn!("Root access limited to ADB only!");
return Ok(Arc::new(SuInfo::deny(uid)));
}
RootAccess::AppsOnly => {
if uid == AID_SHELL {
warn!("Root access is disabled for ADB!");
return Ok(Arc::new(SuInfo::deny(uid)));
}
RootAccess::AppsOnly if uid == AID_SHELL => {
warn!("Root access is disabled for ADB!");
return Ok(Arc::new(SuInfo::deny(uid)));
}
_ => {}
};
+3 -15
View File
@@ -95,26 +95,14 @@ impl MagiskD {
// Check user root access settings
match cfg.root_access {
RootAccess::Disabled => return false,
RootAccess::AppsOnly => {
if uid == AID_SHELL {
return false;
}
}
RootAccess::AdbOnly => {
if uid != AID_SHELL {
return false;
}
}
RootAccess::AppsOnly if uid == AID_SHELL => return false,
RootAccess::AdbOnly if uid != AID_SHELL => return false,
_ => {}
}
// Check multiuser settings
match cfg.multiuser_mode {
MultiuserMode::OwnerOnly => {
if to_user_id(uid) != 0 {
return false;
}
}
MultiuserMode::OwnerOnly if to_user_id(uid) != 0 => return false,
MultiuserMode::OwnerManaged => uid = to_app_id(uid),
_ => {}
}