From 8ccd8f05bdda9842be0c83e36bc30b1bb64bf7cc Mon Sep 17 00:00:00 2001 From: oech3 <79379754+oech3@users.noreply.github.com> Date: Sun, 10 May 2026 15:42:05 +0900 Subject: [PATCH] test_chmod.rs: remove unsafe --- tests/by-util/test_chmod.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/by-util/test_chmod.rs b/tests/by-util/test_chmod.rs index a75324b7c67..e11b62dbe52 100644 --- a/tests/by-util/test_chmod.rs +++ b/tests/by-util/test_chmod.rs @@ -233,20 +233,22 @@ fn test_chmod_ugoa() { } #[test] -#[cfg(any(target_os = "linux", target_os = "macos", target_os = "android"))] +#[cfg(unix)] #[allow(clippy::cast_lossless)] fn test_chmod_umask_expected() { - // Get the actual system umask using libc - let system_umask = unsafe { - let mask = libc::umask(0); - libc::umask(mask); + // Get the actual system umask + let system_umask = { + use rustix::process::umask; + let mask = umask(rustix::fs::Mode::empty()); + umask(mask); mask }; // Now verify that get_umask() returns the same value let current_umask = uucore::mode::get_umask(); assert_eq!( - current_umask, system_umask as u32, + current_umask, + system_umask.bits() as u32, "get_umask() returned {current_umask:03o}, but system umask is {system_umask:03o}", ); }