Merge branch 'master' into 'master'
fix(redox/build): missing unsafe blocks See merge request redox-os/relibc!891
This commit is contained in:
@@ -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(());
|
||||
|
||||
@@ -917,7 +917,9 @@ pub(crate) unsafe fn inner_printf<T: c_str::Kind>(
|
||||
// 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)?;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-2
@@ -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());
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#![allow(unsafe_op_in_unsafe_fn)]
|
||||
|
||||
use core::{
|
||||
convert::TryFrom,
|
||||
mem::{self, MaybeUninit, size_of},
|
||||
|
||||
+3
-1
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user