From 32b93b60563ca0e596d8403c45666cdac624adf1 Mon Sep 17 00:00:00 2001 From: oech3 <79379754+oech3@users.noreply.github.com> Date: Fri, 27 Mar 2026 20:54:09 +0900 Subject: [PATCH] who: reduce range of unsafe (#11521) --- src/uu/who/src/platform/unix.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/uu/who/src/platform/unix.rs b/src/uu/who/src/platform/unix.rs index a91f12fde..6fb70753d 100644 --- a/src/uu/who/src/platform/unix.rs +++ b/src/uu/who/src/platform/unix.rs @@ -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() } }