Merge branch 'sysuio-sysun-tar-cleanup' into 'master'

tar sys_uio and sys_un header cleanup

See merge request redox-os/relibc!1050
This commit is contained in:
Jeremy Soller
2026-02-27 14:21:23 -07:00
5 changed files with 13 additions and 15 deletions
+9 -9
View File
@@ -25,7 +25,7 @@ pub struct iovec {
impl iovec {
unsafe fn to_slice(&self) -> &mut [u8] {
unsafe { slice::from_raw_parts_mut(self.iov_base as *mut u8, self.iov_len as usize) }
unsafe { slice::from_raw_parts_mut(self.iov_base.cast::<u8>(), self.iov_len) }
}
}
@@ -54,7 +54,7 @@ pub unsafe extern "C" fn preadv(
iovcnt: c_int,
offset: off_t,
) -> ssize_t {
if iovcnt < 0 || iovcnt > IOV_MAX {
if !(0..=IOV_MAX).contains(&iovcnt) {
platform::ERRNO.set(errno::EINVAL);
return -1;
}
@@ -62,7 +62,7 @@ pub unsafe extern "C" fn preadv(
let iovs = unsafe { slice::from_raw_parts(iov, iovcnt as usize) };
let mut vec = unsafe { gather(iovs) };
let ret = unsafe { unistd::pread(fd, vec.as_mut_ptr() as *mut c_void, vec.len(), offset) };
let ret = unsafe { unistd::pread(fd, vec.as_mut_ptr().cast::<c_void>(), vec.len(), offset) };
unsafe { scatter(iovs, vec) };
@@ -77,7 +77,7 @@ pub unsafe extern "C" fn pwritev(
iovcnt: c_int,
offset: off_t,
) -> ssize_t {
if iovcnt < 0 || iovcnt > IOV_MAX {
if !(0..=IOV_MAX).contains(&iovcnt) {
platform::ERRNO.set(errno::EINVAL);
return -1;
}
@@ -85,13 +85,13 @@ pub unsafe extern "C" fn pwritev(
let iovs = unsafe { slice::from_raw_parts(iov, iovcnt as usize) };
let vec = unsafe { gather(iovs) };
unsafe { unistd::pwrite(fd, vec.as_ptr() as *const c_void, vec.len(), offset) }
unsafe { unistd::pwrite(fd, vec.as_ptr().cast::<c_void>(), vec.len(), offset) }
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/readv.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn readv(fd: c_int, iov: *const iovec, iovcnt: c_int) -> ssize_t {
if iovcnt < 0 || iovcnt > IOV_MAX {
if !(0..=IOV_MAX).contains(&iovcnt) {
platform::ERRNO.set(errno::EINVAL);
return -1;
}
@@ -99,7 +99,7 @@ pub unsafe extern "C" fn readv(fd: c_int, iov: *const iovec, iovcnt: c_int) -> s
let iovs = unsafe { slice::from_raw_parts(iov, iovcnt as usize) };
let mut vec = unsafe { gather(iovs) };
let ret = unsafe { unistd::read(fd, vec.as_mut_ptr() as *mut c_void, vec.len()) };
let ret = unsafe { unistd::read(fd, vec.as_mut_ptr().cast::<c_void>(), vec.len()) };
unsafe { scatter(iovs, vec) };
@@ -109,7 +109,7 @@ pub unsafe extern "C" fn readv(fd: c_int, iov: *const iovec, iovcnt: c_int) -> s
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/writev.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn writev(fd: c_int, iov: *const iovec, iovcnt: c_int) -> ssize_t {
if iovcnt < 0 || iovcnt > IOV_MAX {
if !(0..=IOV_MAX).contains(&iovcnt) {
platform::ERRNO.set(errno::EINVAL);
return -1;
}
@@ -117,5 +117,5 @@ pub unsafe extern "C" fn writev(fd: c_int, iov: *const iovec, iovcnt: c_int) ->
let iovs = unsafe { slice::from_raw_parts(iov, iovcnt as usize) };
let vec = unsafe { gather(iovs) };
unsafe { unistd::write(fd, vec.as_ptr() as *const c_void, vec.len()) }
unsafe { unistd::write(fd, vec.as_ptr().cast::<c_void>(), vec.len()) }
}
+2 -2
View File
@@ -13,8 +13,8 @@ pub struct sockaddr_un {
impl sockaddr_un {
pub fn path_offset(&self) -> usize {
let base = self as *const _ as usize;
let path = &self.sun_path as *const _ as usize;
let base = core::ptr::from_ref(self) as usize;
let path = &raw const self.sun_path as usize;
log::trace!("base: {:#X}, path: {:#X}", base, path);
path - base
}
+1 -1
View File
@@ -142,7 +142,7 @@ impl TarHeader {
let mut header_copy = *self;
header_copy.chksum.fill(b' ');
let bytes =
unsafe { slice::from_raw_parts(&header_copy as *const _ as *const u8, HEADER_SIZE) };
unsafe { slice::from_raw_parts((&raw const header_copy).cast::<u8>(), HEADER_SIZE) };
bytes.iter().map(|&b| b as usize).sum()
}
}
+1 -1
View File
@@ -84,7 +84,7 @@ pub trait WriteByte: fmt::Write {
fn write_u8(&mut self, byte: u8) -> fmt::Result;
}
impl<'a, W: WriteByte> WriteByte for &'a mut W {
impl<W: WriteByte> WriteByte for &mut W {
fn write_u8(&mut self, byte: u8) -> fmt::Result {
(**self).write_u8(byte)
}
-2
View File
@@ -1,7 +1,5 @@
//! C data types for this platform.
use core::i32;
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help enable
// more optimization opportunities around it recognizing things like
// malloc/free.