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

uptime: use same code structure in two blocks

This commit is contained in:
Daniel Hofstetter 2025-05-06 10:52:59 +02:00
parent 52a2b664e2
commit f6d19fab79

View file

@ -194,17 +194,16 @@ fn uptime_with_file(file_path: &std::ffi::OsString) -> UResult<()> {
#[cfg(target_os = "openbsd")] #[cfg(target_os = "openbsd")]
{ {
user_count = get_nusers(file_path.to_str().expect("invalid utmp path file"));
let upsecs = get_uptime(None); let upsecs = get_uptime(None);
if upsecs < 0 { if upsecs >= 0 {
print_uptime(Some(upsecs))?;
} else {
show_error!("couldn't get boot time"); show_error!("couldn't get boot time");
set_exit_code(1); set_exit_code(1);
print!("up ???? days ??:??,"); print!("up ???? days ??:??,");
} else {
print_uptime(Some(upsecs))?;
} }
user_count = get_nusers(file_path.to_str().expect("invalid utmp path file"));
} }
print_nusers(Some(user_count)); print_nusers(Some(user_count));