1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

chore: manual inline formatting

Minor manual cleanup - inlined many format args.  This makes the code a bit more readable, and helps spot a few inefficiencies and possible bugs.  Note that `&foo` in a `format!` parameter results in a 6% extra performance cost, and does not get inlined by the compiler (yet).
This commit is contained in:
Yuri Astrakhan 2025-04-07 22:56:21 -04:00
parent b7bf8c9467
commit 982805d3cd
29 changed files with 133 additions and 183 deletions

View file

@ -596,7 +596,7 @@ fn get_file_context(path: impl AsRef<Path>) -> Result<Option<String>, selinux::e
let path = path.as_ref();
match selinux::SecurityContext::of_path(path, false, false) {
Err(r) => {
println!("get_file_context failed: '{}': {}.", path.display(), &r);
println!("get_file_context failed: '{}': {r}.", path.display());
Err(r)
}
@ -615,7 +615,7 @@ fn get_file_context(path: impl AsRef<Path>) -> Result<Option<String>, selinux::e
.next()
.unwrap_or_default();
let context = String::from_utf8(bytes.into()).unwrap_or_default();
println!("get_file_context: '{}' => '{}'.", context, path.display());
println!("get_file_context: '{context}' => '{}'.", path.display());
Ok(Some(context))
}
}
@ -632,13 +632,11 @@ fn set_file_context(path: impl AsRef<Path>, context: &str) -> Result<(), selinux
selinux::SecurityContext::from_c_str(&c_context, false).set_for_path(path, false, false);
if let Err(r) = &r {
println!(
"set_file_context failed: '{}' => '{}': {}.",
context,
"set_file_context failed: '{context}' => '{}': {r}.",
path.display(),
r
);
} else {
println!("set_file_context: '{}' => '{}'.", context, path.display());
println!("set_file_context: '{context}' => '{}'.", path.display());
}
r
}