diff --git a/src/header/pty/redox.rs b/src/header/pty/redox.rs index 34d5934ba9..32527576de 100644 --- a/src/header/pty/redox.rs +++ b/src/header/pty/redox.rs @@ -6,7 +6,7 @@ use crate::{ }; pub(super) unsafe fn openpty(name: &mut [u8]) -> Result<(c_int, c_int), ()> { - let master = fcntl::open(c"/scheme/pty".as_ptr(), fcntl::O_RDWR, 0); + let master = unsafe { fcntl::open(c"/scheme/pty".as_ptr(), fcntl::O_RDWR, 0) }; if master < 0 { return Err(()); } @@ -21,7 +21,7 @@ pub(super) unsafe fn openpty(name: &mut [u8]) -> Result<(c_int, c_int), ()> { } name[count as usize] = 0; - let slave = fcntl::open(name.as_ptr() as *const c_char, fcntl::O_RDWR, 0); + let slave = unsafe { fcntl::open(name.as_ptr() as *const c_char, fcntl::O_RDWR, 0) }; if slave < 0 { unistd::close(master); return Err(()); diff --git a/src/header/stdio/printf.rs b/src/header/stdio/printf.rs index 2d8404c609..0c9c1c86fe 100644 --- a/src/header/stdio/printf.rs +++ b/src/header/stdio/printf.rs @@ -917,7 +917,9 @@ pub(crate) unsafe fn inner_printf( // of course be 0, 1 in length let len = 1 + cmp::max(0, exp) as usize; let precision = precision.saturating_sub(len); - fmt_float_normal(w, !alternate, precision, float, left, pad_space, pad_zero)?; + fmt_float_normal( + w, !alternate, precision, float, left, pad_space, pad_zero, + )?; } } else { fmt_float_nonfinite(w, float, fmtcase.unwrap(), left, pad_space, pad_zero)?; diff --git a/src/header/stdlib/mod.rs b/src/header/stdlib/mod.rs index c367e7060f..51657aa350 100644 --- a/src/header/stdlib/mod.rs +++ b/src/header/stdlib/mod.rs @@ -925,7 +925,7 @@ pub unsafe extern "C" fn posix_memalign( #[unsafe(no_mangle)] pub unsafe extern "C" fn posix_openpt(flags: c_int) -> c_int { #[cfg(target_os = "redox")] - let r = open((b"/scheme/pty\0" as *const u8).cast(), O_CREAT); + let r = unsafe { open((b"/scheme/pty\0" as *const u8).cast(), O_CREAT) }; #[cfg(target_os = "linux")] let r = unsafe { open((b"/dev/ptmx\0" as *const u8).cast(), flags) }; @@ -963,10 +963,10 @@ pub unsafe extern "C" fn ptsname_r(fd: c_int, buf: *mut c_char, buflen: size_t) #[cfg(target_os = "redox")] #[inline(always)] unsafe fn __ptsname_r(fd: c_int, buf: *mut c_char, buflen: size_t) -> c_int { - let tty_ptr = unistd::ttyname(fd); + let tty_ptr = unsafe { unistd::ttyname(fd) }; if !tty_ptr.is_null() { - if let Ok(name) = CStr::from_ptr(tty_ptr).to_str() { + if let Ok(name) = unsafe { CStr::from_ptr(tty_ptr) }.to_str() { let len = name.len(); if len > buflen { platform::ERRNO.set(ERANGE); @@ -975,7 +975,9 @@ unsafe fn __ptsname_r(fd: c_int, buf: *mut c_char, buflen: size_t) -> c_int { // we have checked the string will fit in the buffer // so can use strcpy safely let s = name.as_ptr().cast(); - ptr::copy_nonoverlapping(s, buf, len); + unsafe { + ptr::copy_nonoverlapping(s, buf, len); + } return 0; } } diff --git a/src/platform/mod.rs b/src/platform/mod.rs index 2427218381..88b14d6eea 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -338,7 +338,9 @@ pub unsafe fn init(auxvs: Box<[[usize; 2]]>) { let Some(proc_fd) = get_auxv(&auxvs, AT_REDOX_PROC_FD) else { panic!("Missing proc and thread fd!"); }; - redox_rt::initialize(FdGuard::new(proc_fd).to_upper().unwrap()); + unsafe { + redox_rt::initialize(FdGuard::new(proc_fd).to_upper().unwrap()); + } // TODO: Is it safe to assume setup_sighandler has been called at this point? redox_rt::sys::this_proc_call( @@ -352,7 +354,8 @@ pub unsafe fn init(auxvs: Box<[[usize; 2]]>) { get_auxv(&auxvs, AT_REDOX_INITIAL_CWD_PTR), get_auxv(&auxvs, AT_REDOX_INITIAL_CWD_LEN), ) { - let cwd_bytes: &'static [u8] = core::slice::from_raw_parts(cwd_ptr as *const u8, cwd_len); + let cwd_bytes: &'static [u8] = + unsafe { core::slice::from_raw_parts(cwd_ptr as *const u8, cwd_len) }; if let Ok(cwd) = core::str::from_utf8(cwd_bytes) { self::sys::path::set_cwd_manual(cwd.into()); } diff --git a/src/platform/redox/mod.rs b/src/platform/redox/mod.rs index 1b74b5e087..a981f304a6 100644 --- a/src/platform/redox/mod.rs +++ b/src/platform/redox/mod.rs @@ -1,3 +1,5 @@ +#![allow(unsafe_op_in_unsafe_fn)] + use core::{ convert::TryFrom, mem::{self, MaybeUninit, size_of}, diff --git a/src/pthread/mod.rs b/src/pthread/mod.rs index 31e4263429..ad49f731cf 100644 --- a/src/pthread/mod.rs +++ b/src/pthread/mod.rs @@ -226,7 +226,9 @@ unsafe extern "C" fn new_thread_shim( { // `thr_fd` in `tcb` is set by [`Sys::rlct_clone`] *before* jumping to // the entry point of the new thread. - tcb.activate(None); + unsafe { + tcb.activate(None); + } redox_rt::signal::setup_sighandler(&tcb.os_specific, false); } diff --git a/src/start.rs b/src/start.rs index ae47e770ce..4d5257b693 100644 --- a/src/start.rs +++ b/src/start.rs @@ -154,8 +154,10 @@ pub unsafe extern "C" fn relibc_start_v1( #[cfg(target_os = "redox")] let thr_fd = redox_rt::proc::FdGuard::new( - crate::platform::get_auxv_raw(sp.auxv().cast(), redox_rt::auxv_defs::AT_REDOX_THR_FD) - .expect_notls("no thread fd present"), + unsafe { + crate::platform::get_auxv_raw(sp.auxv().cast(), redox_rt::auxv_defs::AT_REDOX_THR_FD) + } + .expect_notls("no thread fd present"), ) .to_upper() .expect_notls("failed to move thread fd to upper table");