Skip to content

Commit def380d

Browse files
oech3cakebaker
authored andcommitted
uutests: remove 1 unsafe
1 parent 94b06d9 commit def380d

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

.vscode/cspell.dictionaries/workspace.wordlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ uutils
364364
execfn
365365
fstatfs
366366
getcwd
367+
mkfifoat
367368
setpipe
368369

369370
# * other

tests/uutests/src/lib/util.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ use pretty_assertions::assert_eq;
2727
use rlimit::setrlimit;
2828
use std::borrow::Cow;
2929
use std::collections::VecDeque;
30-
#[cfg(not(windows))]
31-
use std::ffi::CString;
3230
use std::ffi::{OsStr, OsString};
3331
use std::fs::{self, File, OpenOptions, hard_link, remove_file};
3432
use std::io::{self, BufWriter, Read, Result, Write};
@@ -1165,12 +1163,13 @@ impl AtPath {
11651163

11661164
#[cfg(not(windows))]
11671165
pub fn mkfifo(&self, fifo: &str) {
1166+
// rustix::fs::mkfifoat is linux only
1167+
use nix::sys::stat::Mode;
11681168
let full_path = self.plus_as_string(fifo);
11691169
log_info("mkfifo", &full_path);
1170-
unsafe {
1171-
let fifo_name: CString = CString::new(full_path).expect("CString creation failed.");
1172-
libc::mkfifo(fifo_name.as_ptr(), libc::S_IWUSR | libc::S_IRUSR);
1173-
}
1170+
1171+
let mode = Mode::S_IRUSR | Mode::S_IWUSR;
1172+
nix::unistd::mkfifo(Path::new(&full_path), mode).expect("mkfifo failed");
11741173
}
11751174

11761175
#[cfg(unix)]

0 commit comments

Comments
 (0)