mirror of
https://github.com/uutils/coreutils.git
synced 2025-12-23 08:47:37 +00:00
uucore: fix clippy warnings
This commit is contained in:
parent
5c15d7939b
commit
089faa5c5c
4 changed files with 26 additions and 37 deletions
|
|
@ -79,7 +79,7 @@ fn detect_target_utility() -> Option<String> {
|
|||
// Auto-detect utility name from CARGO_PKG_NAME if it's a uu_* package
|
||||
if let Ok(pkg_name) = env::var("CARGO_PKG_NAME") {
|
||||
if let Some(util_name) = pkg_name.strip_prefix("uu_") {
|
||||
println!("cargo:warning=Auto-detected utility name: {}", util_name);
|
||||
println!("cargo:warning=Auto-detected utility name: {util_name}");
|
||||
return Some(util_name.to_string());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -609,7 +609,7 @@ mod tests {
|
|||
crc.hash_finalize(&mut output);
|
||||
let result = u64::from_ne_bytes(output);
|
||||
|
||||
assert_eq!(result, expected, "CRC mismatch for input: '{}'", input);
|
||||
assert_eq!(result, expected, "CRC mismatch for input: '{input}'");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ mod login {
|
|||
let result = unsafe { ffi::sd_get_sessions(&mut sessions_ptr) };
|
||||
|
||||
if result < 0 {
|
||||
return Err(format!("sd_get_sessions failed: {}", result).into());
|
||||
return Err(format!("sd_get_sessions failed: {result}").into());
|
||||
}
|
||||
|
||||
let mut sessions = Vec::new();
|
||||
|
|
@ -89,11 +89,9 @@ mod login {
|
|||
let result = unsafe { ffi::sd_session_get_uid(session_cstring.as_ptr(), &mut uid) };
|
||||
|
||||
if result < 0 {
|
||||
return Err(format!(
|
||||
"sd_session_get_uid failed for session '{}': {}",
|
||||
session_id, result
|
||||
)
|
||||
.into());
|
||||
return Err(
|
||||
format!("sd_session_get_uid failed for session '{session_id}': {result}",).into(),
|
||||
);
|
||||
}
|
||||
|
||||
Ok(uid)
|
||||
|
|
@ -108,8 +106,7 @@ mod login {
|
|||
|
||||
if result < 0 {
|
||||
return Err(format!(
|
||||
"sd_session_get_start_time failed for session '{}': {}",
|
||||
session_id, result
|
||||
"sd_session_get_start_time failed for session '{session_id}': {result}",
|
||||
)
|
||||
.into());
|
||||
}
|
||||
|
|
@ -125,11 +122,9 @@ mod login {
|
|||
let result = unsafe { ffi::sd_session_get_tty(session_cstring.as_ptr(), &mut tty_ptr) };
|
||||
|
||||
if result < 0 {
|
||||
return Err(format!(
|
||||
"sd_session_get_tty failed for session '{}': {}",
|
||||
session_id, result
|
||||
)
|
||||
.into());
|
||||
return Err(
|
||||
format!("sd_session_get_tty failed for session '{session_id}': {result}",).into(),
|
||||
);
|
||||
}
|
||||
|
||||
if tty_ptr.is_null() {
|
||||
|
|
@ -156,8 +151,7 @@ mod login {
|
|||
|
||||
if result < 0 {
|
||||
return Err(format!(
|
||||
"sd_session_get_remote_host failed for session '{}': {}",
|
||||
session_id, result
|
||||
"sd_session_get_remote_host failed for session '{session_id}': {result}",
|
||||
)
|
||||
.into());
|
||||
}
|
||||
|
|
@ -186,8 +180,7 @@ mod login {
|
|||
|
||||
if result < 0 {
|
||||
return Err(format!(
|
||||
"sd_session_get_display failed for session '{}': {}",
|
||||
session_id, result
|
||||
"sd_session_get_display failed for session '{session_id}': {result}",
|
||||
)
|
||||
.into());
|
||||
}
|
||||
|
|
@ -214,11 +207,9 @@ mod login {
|
|||
let result = unsafe { ffi::sd_session_get_type(session_cstring.as_ptr(), &mut type_ptr) };
|
||||
|
||||
if result < 0 {
|
||||
return Err(format!(
|
||||
"sd_session_get_type failed for session '{}': {}",
|
||||
session_id, result
|
||||
)
|
||||
.into());
|
||||
return Err(
|
||||
format!("sd_session_get_type failed for session '{session_id}': {result}",).into(),
|
||||
);
|
||||
}
|
||||
|
||||
if type_ptr.is_null() {
|
||||
|
|
@ -243,11 +234,9 @@ mod login {
|
|||
let result = unsafe { ffi::sd_session_get_seat(session_cstring.as_ptr(), &mut seat_ptr) };
|
||||
|
||||
if result < 0 {
|
||||
return Err(format!(
|
||||
"sd_session_get_seat failed for session '{}': {}",
|
||||
session_id, result
|
||||
)
|
||||
.into());
|
||||
return Err(
|
||||
format!("sd_session_get_seat failed for session '{session_id}': {result}",).into(),
|
||||
);
|
||||
}
|
||||
|
||||
if seat_ptr.is_null() {
|
||||
|
|
@ -276,11 +265,11 @@ mod login {
|
|||
use std::fs;
|
||||
|
||||
let metadata = fs::metadata("/var/lib/systemd/random-seed")
|
||||
.map_err(|e| format!("Failed to read /var/lib/systemd/random-seed: {}", e))?;
|
||||
.map_err(|e| format!("Failed to read /var/lib/systemd/random-seed: {e}"))?;
|
||||
|
||||
metadata
|
||||
.modified()
|
||||
.map_err(|e| format!("Failed to get modification time: {}", e).into())
|
||||
.map_err(|e| format!("Failed to get modification time: {e}").into())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -396,7 +385,7 @@ pub fn read_login_records() -> UResult<Vec<SystemdLoginRecord>> {
|
|||
.to_string_lossy()
|
||||
.into_owned()
|
||||
} else {
|
||||
format!("{}", uid) // fallback to UID if username not found
|
||||
format!("{uid}") // fallback to UID if username not found
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -484,7 +473,7 @@ pub fn read_login_records() -> UResult<Vec<SystemdLoginRecord>> {
|
|||
if !seat.is_empty() && !tty.is_empty() {
|
||||
// Both seat and tty - need 2 records, clone for first.
|
||||
// The seat is prefixed with '?' to match GNU's output.
|
||||
let seat_formatted = format!("?{}", seat);
|
||||
let seat_formatted = format!("?{seat}");
|
||||
records.push(create_record(
|
||||
seat_formatted,
|
||||
seat,
|
||||
|
|
@ -494,19 +483,19 @@ pub fn read_login_records() -> UResult<Vec<SystemdLoginRecord>> {
|
|||
));
|
||||
|
||||
let tty_formatted = if tty.starts_with("tty") {
|
||||
format!("*{}", tty)
|
||||
format!("*{tty}")
|
||||
} else {
|
||||
tty.clone()
|
||||
};
|
||||
records.push(create_record(tty_formatted, tty, user, session_id, host)); // Move for second (and last) record
|
||||
} else if !seat.is_empty() {
|
||||
// Only seat
|
||||
let seat_formatted = format!("?{}", seat);
|
||||
let seat_formatted = format!("?{seat}");
|
||||
records.push(create_record(seat_formatted, seat, user, session_id, host));
|
||||
} else if !tty.is_empty() {
|
||||
// Only tty
|
||||
let tty_formatted = if tty.starts_with("tty") {
|
||||
format!("*{}", tty)
|
||||
format!("*{tty}")
|
||||
} else {
|
||||
tty.clone()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -705,7 +705,7 @@ mod tests {
|
|||
|
||||
for key in &required_keys {
|
||||
let message = get_message(key);
|
||||
assert_ne!(message, *key, "Translation missing for key: {}", key);
|
||||
assert_ne!(message, *key, "Translation missing for key: {key}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue