From 9ff7b42d832fdc21ef20b02608e9623a4be50f8d Mon Sep 17 00:00:00 2001 From: zhitkoff Date: Fri, 1 Dec 2023 21:00:39 -0500 Subject: [PATCH] wc: stat casting --- src/uu/wc/src/count_fast.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/uu/wc/src/count_fast.rs b/src/uu/wc/src/count_fast.rs index 0d9396740..09b48b21e 100644 --- a/src/uu/wc/src/count_fast.rs +++ b/src/uu/wc/src/count_fast.rs @@ -130,11 +130,12 @@ pub(crate) fn count_bytes_fast(handle: &mut T) -> (usize, Opti // with size that is NOT a multiple of system page size return (stat.st_size as usize, None); } else if let Some(file) = handle.inner_file() { - // On some platforms `stat.st_blksize` is of i32 type, + // On some platforms `stat.st_blksize` and/or `st.st_size` is of i32 type, // i.e. MacOS on Apple Silicon (aarch64-apple-darwin), - // as well as Debian Linux on ARM (aarch64-unknown-linux-gnu) + // as well as Debian Linux on ARM (aarch64-unknown-linux-gnu), etc. #[allow(clippy::unnecessary_cast)] - let offset = stat.st_size - stat.st_size % (stat.st_blksize as i64 + 1); + let offset = + stat.st_size as i64 - stat.st_size as i64 % (stat.st_blksize as i64 + 1); if let Ok(n) = file.seek(SeekFrom::Start(offset as u64)) { byte_count = n as usize;