mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
who: reduce range of unsafe (#11521)
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user