Skip to content

Commit 7b8b24b

Browse files
committed
test_chmod.rs: remove unsafe
1 parent 50ef31a commit 7b8b24b

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

tests/by-util/test_chmod.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,17 +236,19 @@ fn test_chmod_ugoa() {
236236
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "android"))]
237237
#[allow(clippy::cast_lossless)]
238238
fn test_chmod_umask_expected() {
239-
// Get the actual system umask using libc
240-
let system_umask = unsafe {
241-
let mask = libc::umask(0);
242-
libc::umask(mask);
239+
// Get the actual system umask
240+
let system_umask = {
241+
use rustix::process::umask;
242+
let mask = umask(rustix::fs::Mode::empty());
243+
umask(mask);
243244
mask
244245
};
245246

246247
// Now verify that get_umask() returns the same value
247248
let current_umask = uucore::mode::get_umask();
248249
assert_eq!(
249-
current_umask, system_umask as u32,
250+
current_umask,
251+
system_umask.bits() as u32,
250252
"get_umask() returned {current_umask:03o}, but system umask is {system_umask:03o}",
251253
);
252254
}

0 commit comments

Comments
 (0)