From e320c755ff9e14ae18bcba0aea404bada32759c1 Mon Sep 17 00:00:00 2001 From: auronandace Date: Wed, 15 Jul 2026 10:30:48 +0100 Subject: [PATCH] tackle more clippy lints for redox --- src/header/bits_timespec/mod.rs | 4 ++-- src/header/pwd/redox.rs | 2 +- src/header/sys_ioctl/redox/mod.rs | 31 +++++++++++++++--------------- src/header/time/mod.rs | 2 +- src/header/unistd/sysconf.rs | 4 +++- src/header/unistd/sysconf/redox.rs | 6 +++--- src/ld_so/linker.rs | 14 +++++++++++--- src/platform/redox/epoll.rs | 9 ++++----- src/platform/redox/exec.rs | 12 ++++++------ src/platform/redox/extra.rs | 2 +- src/platform/redox/libcscheme.rs | 4 ++-- src/platform/redox/libredox.rs | 22 +++++++++++---------- src/platform/redox/path.rs | 18 ++++++++--------- src/platform/redox/ptrace.rs | 6 +++--- src/platform/redox/signal.rs | 28 +++++++++++++++++++++++---- 15 files changed, 97 insertions(+), 67 deletions(-) diff --git a/src/header/bits_timespec/mod.rs b/src/header/bits_timespec/mod.rs index a8bdb39700..3bf5b34b98 100644 --- a/src/header/bits_timespec/mod.rs +++ b/src/header/bits_timespec/mod.rs @@ -68,13 +68,13 @@ impl<'a> From<&'a syscall::TimeSpec> for timespec { fn from(value: &'a syscall::TimeSpec) -> Self { Self { tv_sec: value.tv_sec as _, - tv_nsec: value.tv_nsec as _, + tv_nsec: value.tv_nsec.into(), } } } #[cfg(target_os = "redox")] -impl<'a> From<&'a timespec> for syscall::TimeSpec { +impl From<×pec> for syscall::TimeSpec { fn from(tp: ×pec) -> Self { Self { tv_sec: tp.tv_sec as _, diff --git a/src/header/pwd/redox.rs b/src/header/pwd/redox.rs index 8b3d723907..28019cc25b 100644 --- a/src/header/pwd/redox.rs +++ b/src/header/pwd/redox.rs @@ -5,7 +5,7 @@ pub fn split(line: &mut [u8]) -> Option { let mut parts = line.split_mut(|&c| c == b'\0'); Some(passwd { pw_name: parts.next()?.as_mut_ptr().cast::(), - pw_passwd: c"x".as_ptr() as *const c_char as *mut c_char, + pw_passwd: c"x".as_ptr().cast::() as *mut c_char, pw_uid: parsed(parts.next())?, pw_gid: parsed(parts.next())?, pw_gecos: parts.next()?.as_mut_ptr().cast::(), diff --git a/src/header/sys_ioctl/redox/mod.rs b/src/header/sys_ioctl/redox/mod.rs index c5100f5f67..8602afac26 100644 --- a/src/header/sys_ioctl/redox/mod.rs +++ b/src/header/sys_ioctl/redox/mod.rs @@ -22,7 +22,8 @@ fn dup_read(fd: c_int, name: &str, t: &mut T) -> syscall::Result { let size = mem::size_of::(); - let bytes = dup.read(unsafe { slice::from_raw_parts_mut(t as *mut T as *mut u8, size) })?; + let bytes = dup + .read(unsafe { slice::from_raw_parts_mut(core::ptr::from_mut::(t) as *mut u8, size) })?; Ok(bytes / size) } @@ -33,7 +34,8 @@ fn dup_write(fd: c_int, name: &str, t: &T) -> Result { let size = mem::size_of::(); - let bytes = dup.write(unsafe { slice::from_raw_parts(t as *const T as *const u8, size) })?; + let bytes = dup + .write(unsafe { slice::from_raw_parts(core::ptr::from_ref::(t) as *const u8, size) })?; Ok(bytes / size) } @@ -50,13 +52,13 @@ impl IoctlBuffer { unsafe fn read(&self) -> Result { let (ptr, size) = match *self { Self::Write(ptr, size) => (ptr, size), - Self::ReadWrite(ptr, size) => (ptr as *const c_void, size), + Self::ReadWrite(ptr, size) => (ptr.cast_const(), size), _ => { return Err(Errno(EINVAL)); } }; if size == mem::size_of::() { - let value = unsafe { ptr::read(ptr as *const T) }; + let value = unsafe { ptr::read(ptr.cast::()) }; Ok(value) } else { Err(Errno(EINVAL)) @@ -64,14 +66,11 @@ impl IoctlBuffer { } unsafe fn write(&mut self, value: T) -> Result<()> { - let (ptr, size) = match *self { - Self::Read(ptr, size) | Self::ReadWrite(ptr, size) => (ptr, size), - _ => { - return Err(Errno(EINVAL)); - } + let (Self::Read(ptr, size) | Self::ReadWrite(ptr, size)) = *self else { + return Err(Errno(EINVAL)); }; if size == mem::size_of::() { - unsafe { ptr::write(ptr as *mut T, value) }; + unsafe { ptr::write(ptr.cast::(), value) }; Ok(()) } else { Err(Errno(EINVAL)) @@ -83,7 +82,7 @@ pub unsafe fn ioctl_inner(fd: c_int, request: c_ulong, out: *mut c_void) -> Resu match request { FIONBIO => { let mut flags = Sys::fcntl(fd, fcntl::F_GETFL, 0)?; - flags = if unsafe { *(out as *mut c_int) } == 0 { + flags = if unsafe { *out.cast::() } == 0 { flags & !fcntl::O_NONBLOCK } else { flags | fcntl::O_NONBLOCK @@ -91,7 +90,7 @@ pub unsafe fn ioctl_inner(fd: c_int, request: c_ulong, out: *mut c_void) -> Resu Sys::fcntl(fd, fcntl::F_SETFL, flags as c_ulonglong)?; } TCGETS => { - let termios = unsafe { &mut *(out as *mut termios::termios) }; + let termios = unsafe { &mut *out.cast::() }; dup_read(fd, "termios", termios)?; } // TODO: give these different behaviors @@ -119,7 +118,7 @@ pub unsafe fn ioctl_inner(fd: c_int, request: c_ulong, out: *mut c_void) -> Resu todo_skip!(0, "ioctl TIOCSCTTY"); } TIOCGPGRP => { - let pgrp = unsafe { &mut *(out as *mut pid_t) }; + let pgrp = unsafe { &mut *out.cast::() }; dup_read(fd, "pgrp", pgrp)?; } TIOCSPGRP => { @@ -127,7 +126,7 @@ pub unsafe fn ioctl_inner(fd: c_int, request: c_ulong, out: *mut c_void) -> Resu dup_write(fd, "pgrp", pgrp)?; } TIOCGWINSZ => { - let winsize = unsafe { &mut *(out as *mut winsize) }; + let winsize = unsafe { &mut *out.cast::() }; dup_read(fd, "winsize", winsize)?; } TIOCSWINSZ => { @@ -135,7 +134,7 @@ pub unsafe fn ioctl_inner(fd: c_int, request: c_ulong, out: *mut c_void) -> Resu dup_write(fd, "winsize", winsize)?; } TIOCGPTLCK => { - let lock = unsafe { &mut *(out as *mut c_int) }; + let lock = unsafe { &mut *out.cast::() }; dup_read(fd, "ptlock", lock)?; } TIOCSPTLCK => { @@ -143,7 +142,7 @@ pub unsafe fn ioctl_inner(fd: c_int, request: c_ulong, out: *mut c_void) -> Resu dup_write(fd, "ptlock", lock)?; } TIOCGPTN => { - let name = unsafe { &mut *(out as *mut c_int) }; + let name = unsafe { &mut *out.cast::() }; dup_read(fd, "ptsname", name)?; } SIOCATMARK => { diff --git a/src/header/time/mod.rs b/src/header/time/mod.rs index 9060918364..351d1244e9 100644 --- a/src/header/time/mod.rs +++ b/src/header/time/mod.rs @@ -72,7 +72,7 @@ pub(crate) struct timer_internal_t { #[cfg(target_os = "redox")] impl timer_internal_t { pub unsafe fn from_raw(timerid: timer_t) -> &'static mut Self { - unsafe { &mut *(timerid as *mut Self) } + unsafe { &mut *timerid.cast::() } } } diff --git a/src/header/unistd/sysconf.rs b/src/header/unistd/sysconf.rs index 0db38b0bbe..50a40fe664 100644 --- a/src/header/unistd/sysconf.rs +++ b/src/header/unistd/sysconf.rs @@ -1,4 +1,6 @@ -/// sysconf.h: . +//! `sysconf.h` implementation. +//! +//! See . #[cfg(target_os = "redox")] #[path = "sysconf/redox.rs"] diff --git a/src/header/unistd/sysconf/redox.rs b/src/header/unistd/sysconf/redox.rs index 3d4f46e627..cc5c6ba35c 100644 --- a/src/header/unistd/sysconf/redox.rs +++ b/src/header/unistd/sysconf/redox.rs @@ -40,7 +40,7 @@ pub(super) fn sysconf_impl(name: c_int) -> c_long { _SC_TIMEOUTS => 202405, _SC_TIMERS => 202405, _SC_SYMLOOP_MAX => -1, - _SC_HOST_NAME_MAX => limits::HOST_NAME_MAX.try_into().unwrap_or(-1), + _SC_HOST_NAME_MAX => limits::HOST_NAME_MAX, _SC_NPROCESSORS_CONF => get_cpu_count().unwrap_or(None).unwrap_or(1), _SC_NPROCESSORS_ONLN => get_cpu_count().unwrap_or(None).unwrap_or(1), _SC_PHYS_PAGES => get_mem_stat().map(|s| s.f_blocks as c_long).unwrap_or(-1), @@ -77,6 +77,6 @@ pub fn get_mem_stat() -> Result { let mut buf = sys_statvfs::statvfs::default(); let res = Sys::fstatvfs(fd, Out::from_mut(&mut buf)); if let Ok(()) = Sys::close(fd) {}; // TODO handle error - let _ = res?; - return Ok(buf); + res?; + Ok(buf) } diff --git a/src/ld_so/linker.rs b/src/ld_so/linker.rs index 56193ff1ab..8fc3f2d71f 100644 --- a/src/ld_so/linker.rs +++ b/src/ld_so/linker.rs @@ -664,14 +664,18 @@ impl Linker { let new_tcb_len = new_tcb.generic.tcb_len; // Unmap just the TCB page. - Sys::munmap(new_tcb as *mut Tcb as *mut c_void, syscall::PAGE_SIZE).unwrap(); + Sys::munmap( + core::ptr::from_mut::(new_tcb) as *mut c_void, + syscall::PAGE_SIZE, + ) + .unwrap(); let new_addr = ptr::addr_of!(*new_tcb) as usize; assert_eq!( syscall::syscall5( syscall::SYS_MREMAP, - old_tcb as *mut Tcb as usize, + core::ptr::from_mut::(old_tcb) as usize, syscall::PAGE_SIZE, new_addr, syscall::PAGE_SIZE, @@ -692,7 +696,11 @@ impl Linker { new_tcb.generic.tcb_len = new_tcb_len; drop(_guard); - (new_tcb, old_tcb as *mut Tcb as *mut c_void, thr_fd) + ( + new_tcb, + core::ptr::from_mut::(old_tcb) as *mut c_void, + thr_fd, + ) }; #[cfg(not(target_os = "redox"))] diff --git a/src/platform/redox/epoll.rs b/src/platform/redox/epoll.rs index 8c0b2d17b7..eddffe42bc 100644 --- a/src/platform/redox/epoll.rs +++ b/src/platform/redox/epoll.rs @@ -104,13 +104,12 @@ impl PalEpoll for Sys { }; let callback = || { - let res = syscall::read(epfd as usize, unsafe { + syscall::read(epfd as usize, unsafe { slice::from_raw_parts_mut( - events as *mut u8, + events.cast::(), maxevents as usize * mem::size_of::(), ) - }); - res + }) }; let bytes_read = if sigset.is_null() { @@ -128,7 +127,7 @@ impl PalEpoll for Sys { unsafe { let event_ptr = events.add(i); let target_ptr = events.add(count); - let event = *(event_ptr as *mut Event); + let event = *event_ptr.cast::(); *target_ptr = epoll_event { events: event_flags_to_epoll(event.flags), data: epoll_data { diff --git a/src/platform/redox/exec.rs b/src/platform/redox/exec.rs index ce088c0e13..6233b5fa11 100644 --- a/src/platform/redox/exec.rs +++ b/src/platform/redox/exec.rs @@ -31,7 +31,7 @@ fn fexec_impl( interp_override: new_interp_override, } = redox_rt::proc::fexec_impl( exec_file, - &RtTcb::current().thread_fd(), + RtTcb::current().thread_fd(), redox_rt::current_proc_fd(), path, args, @@ -49,11 +49,11 @@ fn fexec_impl( // null-terminated. Violating this should therefore give the "format error" ENOEXEC. let path_cstr = CStr::from_bytes_with_nul(&path).map_err(|_| Error::new(ENOEXEC))?; - return execve( + execve( Executable::AtPath(path_cstr), ArgEnv::Parsed { args, envs }, Some(new_interp_override), - ); + ) } pub enum ArgEnv<'a> { @@ -111,9 +111,9 @@ pub fn execve( let Resugid { ruid, rgid, .. } = redox_rt::sys::posix_getresugid(); let mode = if ruid == stat.st_uid { - (stat.st_mode >> 3 * 2) & 0o7 + (stat.st_mode >> (3 * 2)) & 0o7 } else if rgid == stat.st_gid { - (stat.st_mode >> 3 * 1) & 0o7 + (stat.st_mode >> 3) & 0o7 } else { stat.st_mode & 0o7 }; @@ -162,7 +162,7 @@ pub fn execve( let mut args: Vec<&[u8]> = Vec::with_capacity(len); if let Some(interpreter) = &interpreter_path { - image_file = File::open(CStr::borrow(&interpreter), O_RDONLY as c_int) + image_file = File::open(CStr::borrow(interpreter), O_RDONLY as c_int) .map_err(|_| Error::new(ENOENT))?; // Push interpreter to arguments diff --git a/src/platform/redox/extra.rs b/src/platform/redox/extra.rs index 1e3138ed44..d57ff04f8e 100644 --- a/src/platform/redox/extra.rs +++ b/src/platform/redox/extra.rs @@ -11,7 +11,7 @@ pub use redox_rt::proc::FdGuard; #[unsafe(no_mangle)] pub unsafe extern "C" fn redox_fpath(fd: c_int, buf: *mut c_void, count: size_t) -> ssize_t { syscall::fpath(fd as usize, unsafe { - slice::from_raw_parts_mut(buf as *mut u8, count) + slice::from_raw_parts_mut(buf.cast::(), count) }) .map_err(Errno::from) .map(|l| l as ssize_t) diff --git a/src/platform/redox/libcscheme.rs b/src/platform/redox/libcscheme.rs index b4f07ccf6b..0b1a27e189 100644 --- a/src/platform/redox/libcscheme.rs +++ b/src/platform/redox/libcscheme.rs @@ -10,8 +10,8 @@ macro_rules! env_str { ($lit:expr) => { #[allow(unused_unsafe)] { - let val_bytes = unsafe { getenv(concat!($lit, "\0").as_ptr() as *const c_char) }; - if val_bytes != ptr::null_mut() { + let val_bytes = unsafe { getenv(concat!($lit, "\0").as_ptr().cast::()) }; + if !val_bytes.is_null() { if let Ok(val_str) = unsafe { CStr::from_ptr(val_bytes) }.to_str() { Some(val_str) } else { diff --git a/src/platform/redox/libredox.rs b/src/platform/redox/libredox.rs index 166f083536..a6fab15664 100644 --- a/src/platform/redox/libredox.rs +++ b/src/platform/redox/libredox.rs @@ -31,7 +31,7 @@ pub fn openat(dirfd: c_int, path: RedoxStr<'_>, oflag: c_int, mode: mode_t) -> R ((oflag as usize) & 0xFFFF_0000) | ((mode as usize) & 0xFFFF), )?; - if let Err(_) = c_int::try_from(usize_fd) { + if c_int::try_from(usize_fd).is_err() { let _ = redox_rt::sys::close(usize_fd); return Err(Error::new(EMFILE)); } @@ -42,7 +42,7 @@ pub fn fchmod(fd: usize, new_mode: u16) -> Result<()> { std_fs_call_wo( fd, &[], - &StdFsCallMeta::new(StdFsCallKind::Fchmod, new_mode as u64, 0), + &StdFsCallMeta::new(StdFsCallKind::Fchmod, u64::from(new_mode), 0), )?; Ok(()) } @@ -77,7 +77,7 @@ pub fn getdents(fd: usize, buf: &mut [u8], opaque: u64) -> Result { }) => (), other => { //println!("REAL GETDENTS {:?}", other); - return Ok(other?); + return other; } } @@ -87,7 +87,7 @@ pub fn getdents(fd: usize, buf: &mut [u8], opaque: u64) -> Result { let (header, name) = buf.split_at_mut(mem::size_of::()); - let bytes_read = Sys::pread(fd as c_int, name, opaque as i64)? as usize; + let bytes_read = Sys::pread(fd as c_int, name, opaque as i64)?; if bytes_read == 0 { return Ok(0); } @@ -122,14 +122,17 @@ pub unsafe fn fstat(fd: usize, buf: *mut crate::header::sys_stat::stat) -> Resul if let Some(buf) = unsafe { buf.as_mut() } { buf.st_dev = redox_buf.st_dev as dev_t; buf.st_ino = redox_buf.st_ino as ino_t; - buf.st_nlink = redox_buf.st_nlink as nlink_t; + buf.st_nlink = nlink_t::from(redox_buf.st_nlink); buf.st_mode = redox_buf.st_mode as mode_t; buf.st_uid = redox_buf.st_uid as uid_t; buf.st_gid = redox_buf.st_gid as gid_t; // TODO st_rdev buf.st_rdev = 0; buf.st_size = redox_buf.st_size as off_t; + #[cfg(target_pointer_width = "32")] buf.st_blksize = redox_buf.st_blksize as blksize_t; + #[cfg(target_pointer_width = "64")] + buf.st_blksize = blksize_t::from(redox_buf.st_blksize); buf.st_blocks = redox_buf.st_blocks as blkcnt_t; buf.st_atim = timespec { tv_sec: redox_buf.st_atime as time_t, @@ -202,7 +205,7 @@ pub unsafe fn futimens(fd: usize, times: *const timespec) -> Result<()> { }; let redox_buf = unsafe { slice::from_raw_parts( - times.as_ptr() as *const u8, + times.as_ptr().cast::(), times.len() * mem::size_of::(), ) }; @@ -215,7 +218,7 @@ pub unsafe fn futimens(fd: usize, times: *const timespec) -> Result<()> { } pub fn clock_gettime(clock: usize, mut tp: Out) -> Result<()> { let mut redox_tp = syscall::TimeSpec::default(); - syscall::clock_gettime(clock as usize, &mut redox_tp)?; + syscall::clock_gettime(clock, &mut redox_tp)?; tp.write((&redox_tp).into()); Ok(()) } @@ -228,9 +231,8 @@ pub unsafe extern "C" fn redox_open_v1( mode: u16, ) -> RawResult { let path = unsafe { str::from_utf8_unchecked(slice::from_raw_parts(path_base, path_len)) }; - let path = match RedoxStr::new(path) { - Some(path) => path, - None => return Error::mux(Err(Error::new(EINVAL))), + let Some(path) = RedoxStr::new(path) else { + return Error::mux(Err(Error::new(EINVAL))); }; Error::mux(openat(AT_FDCWD, path, flags as c_int, mode as mode_t)) } diff --git a/src/platform/redox/path.rs b/src/platform/redox/path.rs index 55ae546cf8..5eb1551348 100644 --- a/src/platform/redox/path.rs +++ b/src/platform/redox/path.rs @@ -29,7 +29,7 @@ pub fn chdir(path: RedoxStr<'_>) -> Result<()> { let (redox, fd) = match path { RedoxStr::Absolute(path) => { let path = path.to_standard_canon(); - let fd = FdGuard::open_into_upper(&path.as_reference(), O_STAT); + let fd = FdGuard::open_into_upper(path.as_reference(), O_STAT); (path.into_owned(), fd) } RedoxStr::Relative(redox_reference) => { @@ -112,7 +112,7 @@ pub struct Cwd<'a> { static CWD: RwLock>> = RwLock::new(None); pub fn to_cwd_path(path: &str) -> Result { - ArrayString::from_str(&path).or(Err(Error::new(ENAMETOOLONG))) + ArrayString::from_str(path).or(Err(Error::new(ENAMETOOLONG))) } pub fn set_cwd_manual(path: CwdPath, fd: FdGuardUpper) -> Result<()> { @@ -126,7 +126,7 @@ pub fn set_cwd_manual(path: CwdPath, fd: FdGuardUpper) -> Result<()> { pub fn clone_cwd() -> Option { let _siglock = tmp_disable_signals(); - CWD.read().as_ref().map(|cwd| cwd.path.clone()) + CWD.read().as_ref().map(|cwd| cwd.path) } fn open_absolute(path: &str, flags: usize) -> Result { @@ -138,9 +138,9 @@ fn open_absolute(path: &str, flags: usize) -> Result { } // Read symlink content -fn read_link_content<'a, 'b>( +fn read_link_content<'b>( dirfd: Option<&FdGuard>, - path: &'a str, + path: &str, is_relative: bool, ) -> Result> { let resolve_flags = O_CLOEXEC | O_SYMLINK | O_RDONLY; @@ -156,7 +156,7 @@ fn read_link_content<'a, 'b>( log::trace!( "read_link_content ({:?} {:?} {}): {:?}", dirfd, - &path, + path, is_relative, fd ); @@ -180,7 +180,7 @@ fn resolve_sym_links<'a>(mut current_path_string: RedoxPath<'a>, flags: usize) - let dirname = current_path_string.dirname(); let cow: Cow<'_, str> = current_path_string.into(); let initial_res = open_absolute(&cow, flags); - log::trace!("resolve_sym_links({:?}): {:?}", &cow, initial_res); + log::trace!("resolve_sym_links({:?}): {:?}", cow, initial_res); match initial_res { Ok(fd) => return Ok(fd), Err(e) if e == Error::new(EXDEV) => { @@ -384,14 +384,14 @@ fn at_flags_to_open_flags(at_flags: c_int) -> c_int { /// # Arguments /// * `dirfd` is a directory descriptor to which `path` is resolved. /// * `path` is a relative or absolute path. Relative paths are resolved in relation to `dirfd` -/// while absolute paths skip `dirfd`. +/// while absolute paths skip `dirfd`. /// * `at_flags` constrains how `path` is resolved. /// * `oflags` are flags that are passed to open. /// /// # Constants /// `at_flags`: /// * AT_EMPTY_PATH returns the path at `dirfd` itself if `path` is empty. If `path` is not -/// empty, it's resolved w.r.t `dirfd` like normal. +/// empty, it's resolved w.r.t `dirfd` like normal. /// /// `dirfd`: /// `AT_FDCWD` is a special constant for `dirfd` that resolves `path` under the current working diff --git a/src/platform/redox/ptrace.rs b/src/platform/redox/ptrace.rs index eef280d46b..51cb764683 100644 --- a/src/platform/redox/ptrace.rs +++ b/src/platform/redox/ptrace.rs @@ -60,7 +60,7 @@ pub fn init_state() -> &'static State { if STATE.unsafe_ref().is_none() { STATE.unsafe_set(Some(State::new())); } - let state_ptr = STATE.unsafe_ref().as_ref().unwrap() as *const State; + let state_ptr = core::ptr::from_ref::(STATE.unsafe_ref().as_ref().unwrap()); &*state_ptr } } @@ -193,7 +193,7 @@ unsafe fn inner_ptrace( Ok(0) } sys_ptrace::PTRACE_GETREGS => { - let c_regs = unsafe { &mut *(data as *mut user_regs_struct) }; + let c_regs = unsafe { &mut *data.cast::() }; let mut redox_regs = syscall::IntRegisters::default(); (&mut &session.regs).read(&mut redox_regs)?; *c_regs = user_regs_struct { @@ -228,7 +228,7 @@ unsafe fn inner_ptrace( Ok(0) } sys_ptrace::PTRACE_SETREGS => { - let c_regs = unsafe { &*(data as *mut user_regs_struct) }; + let c_regs = unsafe { &*data.cast::() }; let redox_regs = syscall::IntRegisters { r15: c_regs.r15 as _, r14: c_regs.r14 as _, diff --git a/src/platform/redox/signal.rs b/src/platform/redox/signal.rs index c33fb554e2..6d29af132b 100644 --- a/src/platform/redox/signal.rs +++ b/src/platform/redox/signal.rs @@ -115,7 +115,14 @@ impl PalSignal for Sys { SigactionKind::Handled { handler: if c_act.sa_flags & crate::header::signal::SA_SIGINFO as c_int != 0 { SignalHandler { - sigaction: unsafe { core::mem::transmute(c_act.sa_handler) }, + sigaction: unsafe { + core::mem::transmute::< + core::option::Option, + core::option::Option< + unsafe extern "C" fn(i32, *const (), *mut ()), + >, + >(c_act.sa_handler) + }, } } else { SignalHandler { @@ -138,20 +145,33 @@ impl PalSignal for Sys { if let (Some(c_oact), Some(old_action)) = (c_oact, old_action) { *c_oact = match old_action.kind { SigactionKind::Ignore => sigaction { - sa_handler: unsafe { core::mem::transmute(SIG_IGN) }, + sa_handler: unsafe { + core::mem::transmute::>( + SIG_IGN, + ) + }, sa_flags: 0, sa_restorer: None, sa_mask: 0, }, SigactionKind::Default => sigaction { - sa_handler: unsafe { core::mem::transmute(SIG_DFL) }, + sa_handler: unsafe { + core::mem::transmute::>( + SIG_DFL, + ) + }, sa_flags: 0, sa_restorer: None, sa_mask: 0, }, SigactionKind::Handled { handler } => sigaction { sa_handler: if old_action.flags.contains(SigactionFlags::SIGINFO) { - unsafe { core::mem::transmute(handler.sigaction) } + unsafe { + core::mem::transmute::< + core::option::Option, + core::option::Option, + >(handler.sigaction) + } } else { unsafe { handler.handler } },