From 0a8b2c01e9f1ae80969e15330ca2579eb8153a55 Mon Sep 17 00:00:00 2001 From: oech3 <79379754+oech3@users.noreply.github.com> Date: Fri, 27 Mar 2026 20:02:40 +0900 Subject: [PATCH] who: reduce range of unsafe --- 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 a91f12fdeb8..6fb70753dd0 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() } }