From bee63bd24ffccd07f53192aa242d810c9f6672ed Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Wed, 22 May 2024 16:29:09 +0200 Subject: [PATCH] improve readability of readv/writev --- src/syscalls/mod.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/syscalls/mod.rs b/src/syscalls/mod.rs index 09c0a87444..62b46b7c9b 100644 --- a/src/syscalls/mod.rs +++ b/src/syscalls/mod.rs @@ -456,10 +456,10 @@ pub unsafe extern "C" fn sys_readv(fd: i32, iov: *const iovec, iovcnt: i32) -> i } let mut count: isize = 0; - let slice = unsafe { core::slice::from_raw_parts(iov, iovcnt.try_into().unwrap()) }; + let iovec_buffers = unsafe { core::slice::from_raw_parts(iov, iovcnt.try_into().unwrap()) }; - for i in slice { - let buf = unsafe { core::slice::from_raw_parts_mut(i.iov_base, i.iov_len) }; + for iovec_buf in iovec_buffers { + let buf = unsafe { core::slice::from_raw_parts_mut(iovec_buf.iov_base, iovec_buf.iov_len) }; let len = crate::fd::read(fd, buf).map_or_else( |e| -num::ToPrimitive::to_isize(&e).unwrap(), @@ -472,7 +472,7 @@ pub unsafe extern "C" fn sys_readv(fd: i32, iov: *const iovec, iovcnt: i32) -> i count += len; - if len < i.iov_len.try_into().unwrap() { + if len < iovec_buf.iov_len.try_into().unwrap() { return count; } } @@ -517,10 +517,10 @@ pub unsafe extern "C" fn sys_writev(fd: FileDescriptor, iov: *const iovec, iovcn } let mut count: isize = 0; - let slice = unsafe { core::slice::from_raw_parts(iov, iovcnt.try_into().unwrap()) }; + let iovec_buffers = unsafe { core::slice::from_raw_parts(iov, iovcnt.try_into().unwrap()) }; - for i in slice { - let buf = unsafe { core::slice::from_raw_parts(i.iov_base, i.iov_len) }; + for iovec_buf in iovec_buffers { + let buf = unsafe { core::slice::from_raw_parts(iovec_buf.iov_base, iovec_buf.iov_len) }; let len = crate::fd::write(fd, buf).map_or_else( |e| -num::ToPrimitive::to_isize(&e).unwrap(), @@ -533,7 +533,7 @@ pub unsafe extern "C" fn sys_writev(fd: FileDescriptor, iov: *const iovec, iovcn count += len; - if len < i.iov_len.try_into().unwrap() { + if len < iovec_buf.iov_len.try_into().unwrap() { return count; } }