From 9dfb5705c57ceb85c37f33bcae578d2b4a8826c7 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Sat, 17 Jan 2026 01:04:45 +0000 Subject: [PATCH] Remove unnecessary qualification from `size_of` Closes #12339 --- src/ast.rs | 2 +- src/expand.rs | 2 +- src/fd_monitor.rs | 9 ++------- src/fork_exec/postfork.rs | 2 +- src/io.rs | 3 +-- 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/ast.rs b/src/ast.rs index ed912de3e..18c70016e 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -202,7 +202,7 @@ fn source<'s>(&self, orig: &'s wstr) -> &'s wstr { /// The raw byte size of this node, excluding children. /// This also excludes the allocations stored in lists. fn self_memory_size(&self) -> usize { - std::mem::size_of_val(self) + size_of_val(self) } } diff --git a/src/expand.rs b/src/expand.rs index e647701f9..a2730edcd 100644 --- a/src/expand.rs +++ b/src/expand.rs @@ -1166,7 +1166,7 @@ fn expand_home_directory(input: &mut WString, vars: &dyn Environment) { name_cstr.as_ptr(), userinfo.as_mut_ptr(), &mut buf[0], - std::mem::size_of_val(&buf), + size_of_val(&buf), &mut result, ) }; diff --git a/src/fd_monitor.rs b/src/fd_monitor.rs index 2aa11a5d5..f974635a8 100644 --- a/src/fd_monitor.rs +++ b/src/fd_monitor.rs @@ -88,13 +88,8 @@ pub fn try_consume(&self) -> bool { ); let mut ret; loop { - ret = unsafe { - libc::read( - self.read_fd(), - buff.as_mut_ptr().cast(), - std::mem::size_of_val(&buff), - ) - }; + ret = + unsafe { libc::read(self.read_fd(), buff.as_mut_ptr().cast(), size_of_val(&buff)) }; if ret >= 0 || errno().0 != EINTR { break; } diff --git a/src/fork_exec/postfork.rs b/src/fork_exec/postfork.rs index c59e6e612..29e03bcee 100644 --- a/src/fork_exec/postfork.rs +++ b/src/fork_exec/postfork.rs @@ -503,7 +503,7 @@ fn get_interpreter<'a>(command: &CStr, buffer: &'a mut [u8]) -> Option<&'a CStr> if fd >= 0 { while idx + 1 < buffer.len() { let mut ch = b'\0'; - let amt = unsafe { libc::read(fd, (&raw mut ch).cast(), std::mem::size_of_val(&ch)) }; + let amt = unsafe { libc::read(fd, (&raw mut ch).cast(), size_of_val(&ch)) }; if amt <= 0 || ch == b'\n' { break; } diff --git a/src/io.rs b/src/io.rs index 5b2d1775e..c2282c815 100644 --- a/src/io.rs +++ b/src/io.rs @@ -420,8 +420,7 @@ pub fn read_once(fd: RawFd, buffer: &mut MutexGuard<'_, SeparatedBuffer>) -> isi // We want to swallow EINTR only; in particular EAGAIN needs to be returned back to the caller. let amt = loop { - let amt = - unsafe { libc::read(fd, bytes.as_mut_ptr().cast(), std::mem::size_of_val(&bytes)) }; + let amt = unsafe { libc::read(fd, bytes.as_mut_ptr().cast(), size_of_val(&bytes)) }; if amt < 0 && errno::errno().0 == EINTR { continue; }