Run cargo fmt

This commit is contained in:
topjohnwu
2025-09-02 11:11:49 -07:00
committed by John Wu
parent bd657c354c
commit bc89c60977
4 changed files with 29 additions and 22 deletions

View File

@@ -111,9 +111,10 @@ pub(crate) unsafe fn readlinkat(
unsafe extern "C" fn cp_afc_for_cxx(src: *const c_char, dest: *const c_char) -> bool { unsafe extern "C" fn cp_afc_for_cxx(src: *const c_char, dest: *const c_char) -> bool {
unsafe { unsafe {
if let Ok(src) = Utf8CStr::from_ptr(src) if let Ok(src) = Utf8CStr::from_ptr(src)
&& let Ok(dest) = Utf8CStr::from_ptr(dest) { && let Ok(dest) = Utf8CStr::from_ptr(dest)
return src.copy_to(dest).log_cxx().is_ok(); {
} return src.copy_to(dest).log_cxx().is_ok();
}
false false
} }
} }
@@ -122,9 +123,10 @@ unsafe extern "C" fn cp_afc_for_cxx(src: *const c_char, dest: *const c_char) ->
unsafe extern "C" fn mv_path_for_cxx(src: *const c_char, dest: *const c_char) -> bool { unsafe extern "C" fn mv_path_for_cxx(src: *const c_char, dest: *const c_char) -> bool {
unsafe { unsafe {
if let Ok(src) = Utf8CStr::from_ptr(src) if let Ok(src) = Utf8CStr::from_ptr(src)
&& let Ok(dest) = Utf8CStr::from_ptr(dest) { && let Ok(dest) = Utf8CStr::from_ptr(dest)
return src.move_to(dest).log_cxx().is_ok(); {
} return src.move_to(dest).log_cxx().is_ok();
}
false false
} }
} }
@@ -133,9 +135,10 @@ unsafe extern "C" fn mv_path_for_cxx(src: *const c_char, dest: *const c_char) ->
unsafe extern "C" fn link_path_for_cxx(src: *const c_char, dest: *const c_char) -> bool { unsafe extern "C" fn link_path_for_cxx(src: *const c_char, dest: *const c_char) -> bool {
unsafe { unsafe {
if let Ok(src) = Utf8CStr::from_ptr(src) if let Ok(src) = Utf8CStr::from_ptr(src)
&& let Ok(dest) = Utf8CStr::from_ptr(dest) { && let Ok(dest) = Utf8CStr::from_ptr(dest)
return src.link_to(dest).log_cxx().is_ok(); {
} return src.link_to(dest).log_cxx().is_ok();
}
false false
} }
} }
@@ -144,9 +147,10 @@ unsafe extern "C" fn link_path_for_cxx(src: *const c_char, dest: *const c_char)
unsafe extern "C" fn clone_attr_for_cxx(src: *const c_char, dest: *const c_char) -> bool { unsafe extern "C" fn clone_attr_for_cxx(src: *const c_char, dest: *const c_char) -> bool {
unsafe { unsafe {
if let Ok(src) = Utf8CStr::from_ptr(src) if let Ok(src) = Utf8CStr::from_ptr(src)
&& let Ok(dest) = Utf8CStr::from_ptr(dest) { && let Ok(dest) = Utf8CStr::from_ptr(dest)
return clone_attr(src, dest).log_cxx().is_ok(); {
} return clone_attr(src, dest).log_cxx().is_ok();
}
false false
} }
} }

View File

@@ -211,10 +211,11 @@ fn dtb_test(file: &Utf8CStr) -> LoggedResult<bool> {
continue; continue;
} }
if let Some(mount_point) = child.property("mnt_point") if let Some(mount_point) = child.property("mnt_point")
&& mount_point.value == b"/system_root\0" { && mount_point.value == b"/system_root\0"
ret = false; {
break; ret = false;
} break;
}
} }
} }
Ok(()) Ok(())

View File

@@ -29,9 +29,10 @@ pub(crate) fn switch_root(path: &Utf8CStr) {
if let Some(last_mount) = mounts if let Some(last_mount) = mounts
.range::<String, _>((Unbounded, Excluded(&info.target))) .range::<String, _>((Unbounded, Excluded(&info.target)))
.last() .last()
&& info.target.starts_with(&format!("{}/", *last_mount)) { && info.target.starts_with(&format!("{}/", *last_mount))
continue; {
} continue;
}
let mut target = info.target.clone(); let mut target = info.target.clone();
let target = Utf8CStr::from_string(&mut target); let target = Utf8CStr::from_string(&mut target);

View File

@@ -128,9 +128,10 @@ pub unsafe extern "C" fn main(
} }
if let Some(file) = cli.save if let Some(file) = cli.save
&& !sepol.to_file(&file) { && !sepol.to_file(&file)
log_err!("Cannot dump policy to {}", file)?; {
} log_err!("Cannot dump policy to {}", file)?;
}
}; };
if res.is_ok() { 0 } else { 1 } if res.is_ok() { 0 } else { 1 }
} }