who: reduce range of unsafe (#11521)

This commit is contained in:
oech3
2026-03-27 12:54:09 +01:00
committed by GitHub
parent 2b05f2fa8c
commit 32b93b6056
+8 -10
View File
@@ -179,16 +179,14 @@ fn time_string(ut: &UtmpxRecord) -> String {
#[inline]
fn current_tty() -> String {
unsafe {
let res = ttyname(STDIN_FILENO);
if res.is_null() {
String::new()
} else {
CStr::from_ptr(res.cast_const())
.to_string_lossy()
.trim_start_matches("/dev/")
.to_owned()
}
let p = unsafe { ttyname(STDIN_FILENO) };
if p.is_null() {
String::new()
} else {
unsafe { CStr::from_ptr(p) }
.to_string_lossy()
.trim_start_matches("/dev/")
.to_owned()
}
}