From ca5dc954b74e02b8a5389eac3f25de5e262a3c8b Mon Sep 17 00:00:00 2001 From: oech3 <79379754+oech3@users.noreply.github.com> Date: Tue, 9 Jun 2026 15:23:39 +0900 Subject: [PATCH] wc: drop guard for non FIFO stream --- src/uu/wc/src/count_fast.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/uu/wc/src/count_fast.rs b/src/uu/wc/src/count_fast.rs index c4281eac22..b9f77820ae 100644 --- a/src/uu/wc/src/count_fast.rs +++ b/src/uu/wc/src/count_fast.rs @@ -55,8 +55,7 @@ fn count_bytes_using_splice(fd: &impl rustix::fd::AsFd) -> Result /// In the special case where we only need to count the number of bytes. There /// are several optimizations we can do: /// 1. On Unix, we can simply `stat` the file if it is regular. -/// 2. On Linux -- if the above did not work -- we can use splice to count -/// the number of bytes if the file is a FIFO. +/// 2. On Linux -- if the above did not work -- we can use splice with broker /// 3. On Windows we can use `std::os::windows::fs::MetadataExt` to get file size /// for regular files /// 3. Otherwise, we just read normally, but without the overhead of counting @@ -131,14 +130,11 @@ pub(crate) fn count_bytes_fast(handle: &mut T) -> (usize, Opti } } } - // Else, if we're on Linux and our file is a FIFO pipe - // (or stdin), we use splice to count the number of bytes. + // Else, if we're on Linux, we use splice with broker (mostly for stream) #[cfg(any(target_os = "linux", target_os = "android"))] - if (stat.st_mode as libc::mode_t & libc::S_IFIFO) != 0 { - match count_bytes_using_splice(handle) { - Ok(n) => return (n, None), - Err(n) => byte_count = n, - } + match count_bytes_using_splice(handle) { + Ok(n) => return (byte_count + n, None), + Err(n) => byte_count += n, } } }