mirror of
https://github.com/kvorschk/Magisk.git
synced 2026-12-05 03:20:46 -05:00
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:
@@ -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)?;
|
||||
}
|
||||
|
||||
@@ -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
@@ -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;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
|
||||
@@ -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),
|
||||
_ => {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user