From 8deb1f32c31f8782780cb48abfe114acc705b724 Mon Sep 17 00:00:00 2001 From: auronandace Date: Mon, 22 Dec 2025 17:40:51 +0000 Subject: [PATCH 1/2] mark two functions unsafe --- src/header/unistd/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/header/unistd/mod.rs b/src/header/unistd/mod.rs index 590546ddbd..cd3072c17d 100644 --- a/src/header/unistd/mod.rs +++ b/src/header/unistd/mod.rs @@ -197,7 +197,7 @@ pub extern "C" fn close(fildes: c_int) -> c_int { /// See . #[unsafe(no_mangle)] -pub extern "C" fn confstr(name: c_int, buf: *mut c_char, len: size_t) -> size_t { +pub unsafe extern "C" fn confstr(name: c_int, buf: *mut c_char, len: size_t) -> size_t { // confstr returns the number of bytes required to hold the string INCLUDING the NUL // terminator. This is different from other C functions hence the + 1. match name { @@ -1002,7 +1002,7 @@ pub extern "C" fn sleep(seconds: c_uint) -> c_uint { /// See . #[unsafe(no_mangle)] -pub extern "C" fn swab(src: *const c_void, dest: *mut c_void, nbytes: ssize_t) { +pub unsafe extern "C" fn swab(src: *const c_void, dest: *mut c_void, nbytes: ssize_t) { if nbytes <= 0 { return; } From 8414205d04b9172478893f5e0e5641d4a9e287ea Mon Sep 17 00:00:00 2001 From: auronandace Date: Mon, 22 Dec 2025 17:47:29 +0000 Subject: [PATCH 2/2] only import the needed types --- src/header/unistd/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/header/unistd/mod.rs b/src/header/unistd/mod.rs index cd3072c17d..19d57a280f 100644 --- a/src/header/unistd/mod.rs +++ b/src/header/unistd/mod.rs @@ -21,7 +21,13 @@ use crate::{ time::timespec, }, out::Out, - platform::{self, ERRNO, Pal, Sys, types::*}, + platform::{ + self, ERRNO, Pal, Sys, + types::{ + c_char, c_int, c_long, c_short, c_uint, c_ulonglong, c_void, gid_t, off_t, pid_t, + size_t, ssize_t, suseconds_t, time_t, uid_t, useconds_t, + }, + }, }; pub use self::{brk::*, getopt::*, getpass::getpass, pathconf::*, sysconf::*};