From def380d7c7eb284f33b1f832fc531028b37f88b1 Mon Sep 17 00:00:00 2001 From: oech3 <79379754+oech3@users.noreply.github.com> Date: Mon, 11 May 2026 12:42:43 +0900 Subject: [PATCH] uutests: remove 1 unsafe --- .vscode/cspell.dictionaries/workspace.wordlist.txt | 1 + tests/uutests/src/lib/util.rs | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.vscode/cspell.dictionaries/workspace.wordlist.txt b/.vscode/cspell.dictionaries/workspace.wordlist.txt index 2faa150d3..af5350720 100644 --- a/.vscode/cspell.dictionaries/workspace.wordlist.txt +++ b/.vscode/cspell.dictionaries/workspace.wordlist.txt @@ -364,6 +364,7 @@ uutils execfn fstatfs getcwd +mkfifoat setpipe # * other diff --git a/tests/uutests/src/lib/util.rs b/tests/uutests/src/lib/util.rs index 3a95da0de..1c8d04593 100644 --- a/tests/uutests/src/lib/util.rs +++ b/tests/uutests/src/lib/util.rs @@ -27,8 +27,6 @@ use pretty_assertions::assert_eq; use rlimit::setrlimit; use std::borrow::Cow; use std::collections::VecDeque; -#[cfg(not(windows))] -use std::ffi::CString; use std::ffi::{OsStr, OsString}; use std::fs::{self, File, OpenOptions, hard_link, remove_file}; use std::io::{self, BufWriter, Read, Result, Write}; @@ -1165,12 +1163,13 @@ impl AtPath { #[cfg(not(windows))] pub fn mkfifo(&self, fifo: &str) { + // rustix::fs::mkfifoat is linux only + use nix::sys::stat::Mode; let full_path = self.plus_as_string(fifo); log_info("mkfifo", &full_path); - unsafe { - let fifo_name: CString = CString::new(full_path).expect("CString creation failed."); - libc::mkfifo(fifo_name.as_ptr(), libc::S_IWUSR | libc::S_IRUSR); - } + + let mode = Mode::S_IRUSR | Mode::S_IWUSR; + nix::unistd::mkfifo(Path::new(&full_path), mode).expect("mkfifo failed"); } #[cfg(unix)]