mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
test_chmod.rs: remove unsafe
This commit is contained in:
@@ -233,20 +233,22 @@ fn test_chmod_ugoa() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "android"))]
|
#[cfg(unix)]
|
||||||
#[allow(clippy::cast_lossless)]
|
#[allow(clippy::cast_lossless)]
|
||||||
fn test_chmod_umask_expected() {
|
fn test_chmod_umask_expected() {
|
||||||
// Get the actual system umask using libc
|
// Get the actual system umask
|
||||||
let system_umask = unsafe {
|
let system_umask = {
|
||||||
let mask = libc::umask(0);
|
use rustix::process::umask;
|
||||||
libc::umask(mask);
|
let mask = umask(rustix::fs::Mode::empty());
|
||||||
|
umask(mask);
|
||||||
mask
|
mask
|
||||||
};
|
};
|
||||||
|
|
||||||
// Now verify that get_umask() returns the same value
|
// Now verify that get_umask() returns the same value
|
||||||
let current_umask = uucore::mode::get_umask();
|
let current_umask = uucore::mode::get_umask();
|
||||||
assert_eq!(
|
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}",
|
"get_umask() returned {current_umask:03o}, but system umask is {system_umask:03o}",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user