From 2d3ee10aefdf291fc502c3fb3f76cb1273716c4c Mon Sep 17 00:00:00 2001 From: auronandace Date: Fri, 27 Feb 2026 21:38:16 +0000 Subject: [PATCH] platform and pthread cleanup --- src/platform/linux/mod.rs | 8 ++++---- src/platform/linux/signal.rs | 18 +++++++++--------- src/platform/mod.rs | 2 +- src/pthread/mod.rs | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/platform/linux/mod.rs b/src/platform/linux/mod.rs index 008718a234..fc968aeba6 100644 --- a/src/platform/linux/mod.rs +++ b/src/platform/linux/mod.rs @@ -160,7 +160,7 @@ impl Pal for Sys { envp: *const *mut c_char, ) -> Result<()> { let empty = b"\0"; - let empty_ptr = empty.as_ptr() as *const c_char; + let empty_ptr = empty.as_ptr().cast::(); e_raw(syscall!( EXECVEAT, fildes, @@ -218,7 +218,7 @@ impl Pal for Sys { fn fstat(fildes: c_int, mut buf: Out) -> Result<()> { let empty = b"\0"; - let empty_ptr = empty.as_ptr() as *const c_char; + let empty_ptr = empty.as_ptr().cast::(); e_raw(unsafe { syscall!( NEWFSTATAT, @@ -248,7 +248,7 @@ impl Pal for Sys { let buf = buf.as_mut_ptr(); let mut kbuf = linux_statfs::default(); - let kbuf_ptr = &mut kbuf as *mut linux_statfs; + let kbuf_ptr = &raw mut kbuf; e_raw(unsafe { syscall!(FSTATFS, fildes, kbuf_ptr) })?; if !buf.is_null() { @@ -296,7 +296,7 @@ impl Pal for Sys { #[inline] unsafe fn futex_wait(addr: *mut u32, val: u32, deadline: Option<×pec>) -> Result<()> { - let deadline = deadline.map_or(0, |d| d as *const _ as usize); + let deadline = deadline.map_or(0, |d| ptr::from_ref(d) as usize); e_raw(unsafe { syscall!( FUTEX, addr, // uaddr diff --git a/src/platform/linux/signal.rs b/src/platform/linux/signal.rs index 2dd8738834..da2119d47b 100644 --- a/src/platform/linux/signal.rs +++ b/src/platform/linux/signal.rs @@ -62,7 +62,7 @@ impl PalSignal for Sys { SETITIMER, which, ptr::from_ref(new), - old.map_or_else(ptr::null_mut, |r| ptr::from_mut(r)) + old.map_or_else(ptr::null_mut, ptr::from_mut) ) })?; Ok(()) @@ -86,8 +86,8 @@ impl PalSignal for Sys { syscall!( RT_SIGACTION, sig, - act.as_ref().map_or_else(ptr::null, |x| ptr::from_ref(x)), - oact.map_or_else(ptr::null_mut, |x| ptr::from_mut(x)), + act.as_ref().map_or_else(ptr::null, ptr::from_ref), + oact.map_or_else(ptr::null_mut, ptr::from_mut), mem::size_of::() ) }) @@ -97,8 +97,8 @@ impl PalSignal for Sys { unsafe fn sigaltstack(ss: Option<&stack_t>, old_ss: Option<&mut stack_t>) -> Result<()> { e_raw(syscall!( SIGALTSTACK, - ss.map_or_else(ptr::null, |x| ptr::from_ref(x)), - old_ss.map_or_else(ptr::null_mut, |x| ptr::from_mut(x)) + ss.map_or_else(ptr::null, ptr::from_ref), + old_ss.map_or_else(ptr::null_mut, ptr::from_mut) )) .map(|_| ()) } @@ -119,8 +119,8 @@ impl PalSignal for Sys { syscall!( RT_SIGPROCMASK, how, - set.map_or_else(ptr::null, |x| ptr::from_ref(x)), - oset.map_or_else(ptr::null_mut, |x| ptr::from_mut(x)), + set.map_or_else(ptr::null, ptr::from_ref), + oset.map_or_else(ptr::null_mut, ptr::from_mut), mem::size_of::() ) }) @@ -147,8 +147,8 @@ impl PalSignal for Sys { e_raw(syscall!( RT_SIGTIMEDWAIT, ptr::from_ref(set), - sig.map_or_else(ptr::null_mut, |s| ptr::from_mut(s)), - tp.map_or_else(ptr::null, |t| ptr::from_ref(t)), + sig.map_or_else(ptr::null_mut, ptr::from_mut), + tp.map_or_else(ptr::null, ptr::from_ref), size_of::() )) .map(|s| s as c_int) diff --git a/src/platform/mod.rs b/src/platform/mod.rs index a61c6a2c00..e39432938d 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -263,7 +263,7 @@ impl Write for CountingWriter { res } fn write_all(&mut self, buf: &[u8]) -> io::Result<()> { - match self.inner.write_all(&buf) { + match self.inner.write_all(buf) { Ok(()) => (), Err(ref err) if err.kind() == io::ErrorKind::WriteZero => (), Err(err) => return Err(err), diff --git a/src/pthread/mod.rs b/src/pthread/mod.rs index 0f39be3772..8243a48079 100644 --- a/src/pthread/mod.rs +++ b/src/pthread/mod.rs @@ -168,7 +168,7 @@ pub(crate) unsafe fn create( new_tcb.mspace = current_tcb.mspace; let stack_end = unsafe { stack_base.add(stack_size) }; - let mut stack = stack_end as *mut usize; + let mut stack = stack_end.cast::(); { let mut push = |value: usize| { stack = unsafe { stack.sub(1) }; @@ -184,8 +184,8 @@ pub(crate) unsafe fn create( } push(0); push(0); - push(synchronization_mutex as *const _ as usize); - push(new_tcb as *mut _ as usize); + push(ptr::from_ref(synchronization_mutex) as usize); + push(ptr::from_mut(new_tcb) as usize); push(arg as usize); push(start_routine as usize); @@ -204,7 +204,7 @@ pub(crate) unsafe fn create( .lock() .insert(os_tid, ForceSendSync(new_tcb)); - Ok((&new_tcb.pthread) as *const _ as *mut _) + Ok(&raw const new_tcb.pthread as *mut _) } /// A shim to wrap thread entry points in logic to set up TLS, for example