Merge branch 'deny-deprecated' into 'master'

set 'deprecated' lint to 'deny'

See merge request redox-os/relibc!1208
This commit is contained in:
Jeremy Soller
2026-04-20 16:27:58 -06:00
18 changed files with 135 additions and 47 deletions
+1 -1
View File
@@ -41,7 +41,7 @@ zero_ptr = "warn" # must allow on public constants due to cbindgen issue
[workspace.lints.rust]
dangling_pointers_from_temporaries = "deny"
dead_code = "allow" # TODO review occuurences
deprecated = "allow" # TODO review occuurences
deprecated = "deny"
improper_ctypes_definitions = "deny"
internal_features = "allow" # core_intrinsics and lang_items
irrefutable_let_patterns = "deny"
+4 -1
View File
@@ -145,7 +145,10 @@ pub extern "C" fn inet_netof(r#in: in_addr) -> in_addr_t {
#[deprecated]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn inet_network(cp: *const c_char) -> in_addr_t {
ntohl(unsafe { inet_addr(cp) })
ntohl(unsafe {
#[allow(deprecated)]
inet_addr(cp)
})
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/inet_addr.html>.
+5 -1
View File
@@ -348,7 +348,10 @@ pub unsafe extern "C" fn gethostbyname(name: *const c_char) -> *mut hostent {
// Some implementations just skip resolution and copy the address to h_name
if let Some(s_addr) = parse_ipv4_string(name_str) {
let addr = in_addr { s_addr };
return unsafe { gethostbyaddr(ptr::from_ref(&addr).cast::<c_void>(), 4, AF_INET) };
return unsafe {
#[allow(deprecated)]
gethostbyaddr(ptr::from_ref(&addr).cast::<c_void>(), 4, AF_INET)
};
}
// check the hosts file first
@@ -1137,6 +1140,7 @@ pub extern "C" fn herror(prefix: *const c_char) {
let code = H_ERRNO.get();
// Safety: `hstrerror` handles every error code case and always returns a valid C string
let error = unsafe {
#[allow(deprecated)]
let msg_cstr = CStr::from_ptr(hstrerror(code));
str::from_utf8_unchecked(msg_cstr.to_bytes())
};
+1
View File
@@ -292,6 +292,7 @@ pub extern "C" fn sigignore(sig: c_int) -> c_int {
/// See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/siginterrupt.html>.
///
/// Marked obsolescent in issue 7. Removed in issue 8.
#[deprecated]
#[unsafe(no_mangle)]
pub extern "C" fn siginterrupt(sig: c_int, flag: c_int) -> c_int {
let mut psa = mem::MaybeUninit::<sigaction>::uninit();
+21 -3
View File
@@ -315,6 +315,7 @@ pub unsafe extern "C" fn ctermid(s: *mut c_char) -> *mut c_char {
///
/// Marked legacy in SUS Version 2.
// #[unsafe(no_mangle)]
#[deprecated]
pub unsafe extern "C" fn cuserid(s: *mut c_char) -> *mut c_char {
let mut buf: Vec<c_char> = vec![0; 256];
let mut pwd: pwd::passwd = unsafe { mem::zeroed() };
@@ -894,6 +895,7 @@ pub unsafe extern "C" fn getchar_unlocked() -> c_int {
/// `fgets` is recommended instead, which is what this implementation calls.
///
/// Get a string from `stdin`
#[deprecated]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn gets(s: *mut c_char) -> *mut c_char {
unsafe { fgets(s, c_int::MAX, &raw mut *stdin) }
@@ -904,6 +906,7 @@ pub unsafe extern "C" fn gets(s: *mut c_char) -> *mut c_char {
/// Was marked legacy and removed in issue 6.
///
/// Get an integer from `stream`
#[deprecated]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn getw(stream: *mut FILE) -> c_int {
let mut ret: c_int = 0;
@@ -1125,6 +1128,7 @@ pub unsafe extern "C" fn puts(s: *const c_char) -> c_int {
/// Marked legacy in SUS Version 2.
///
/// Put an integer `w` into `stream`
#[deprecated]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn putw(w: c_int, stream: *mut FILE) -> c_int {
(unsafe {
@@ -1258,6 +1262,7 @@ pub unsafe extern "C" fn setvbuf(
/// See <https://pubs.opengroup.org/onlinepubs/009604599/functions/tempnam.html>.
///
/// Marked obsolescent in issue 7.
#[deprecated]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn tempnam(dir: *const c_char, pfx: *const c_char) -> *mut c_char {
unsafe fn is_appropriate(pos_dir: *const c_char) -> bool {
@@ -1294,7 +1299,12 @@ pub unsafe extern "C" fn tempnam(dir: *const c_char, pfx: *const c_char) -> *mut
};
// use the same mechanism as tmpnam to get the file name
if unsafe { tmpnam_inner(out_buf, dirname_len + 1 + prefix_len) }.is_null() {
if unsafe {
#[allow(deprecated)]
tmpnam_inner(out_buf, dirname_len + 1 + prefix_len)
}
.is_null()
{
// failed to find a valid file name, so we need to free the buffer
unsafe { platform::free(out_buf.cast()) };
out_buf = ptr::null_mut();
@@ -1331,6 +1341,7 @@ pub unsafe extern "C" fn tmpfile() -> *mut FILE {
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/tmpnam.html>.
///
/// Marked obsolescent in issue 7.
#[deprecated]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn tmpnam(s: *mut c_char) -> *mut c_char {
let buf = if s.is_null() {
@@ -1340,9 +1351,13 @@ pub unsafe extern "C" fn tmpnam(s: *mut c_char) -> *mut c_char {
};
unsafe { *buf = b'/' as _ };
unsafe { tmpnam_inner(buf, 1) }
unsafe {
#[allow(deprecated)]
tmpnam_inner(buf, 1)
}
}
#[deprecated]
unsafe extern "C" fn tmpnam_inner(buf: *mut c_char, offset: usize) -> *mut c_char {
const TEMPLATE: &[u8] = b"XXXXXX\0";
@@ -1352,7 +1367,10 @@ unsafe extern "C" fn tmpnam_inner(buf: *mut c_char, offset: usize) -> *mut c_cha
};
let err = platform::ERRNO.get();
unsafe { stdlib::mktemp(buf) };
unsafe {
#[allow(deprecated)]
stdlib::mktemp(buf)
};
platform::ERRNO.set(err);
if unsafe { *buf } == 0 {
+4 -3
View File
@@ -146,9 +146,9 @@ pub unsafe extern "C" fn aligned_alloc(alignment: size_t, size: size_t) -> *mut
platform::ERRNO.set(EINVAL);
return ptr::null_mut();
}
/* The size-is-multiple-of-alignment requirement is the only
* difference between aligned_alloc() and memalign(). */
unsafe { memalign(alignment, size) }
let mut pointer = ptr::null_mut();
unsafe { posix_memalign(ptr::from_mut(&mut pointer), alignment, size) };
pointer
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/at_quick_exit.html>.
@@ -1113,6 +1113,7 @@ pub unsafe extern "C" fn rand() -> c_int {
/// # Deprecation
/// The `rand_r()` function was marked as obsolescent in the Open Group Base
/// Specifications Issue 7, and the function was removed in Issue 8.
#[deprecated]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn rand_r(seed: *mut c_uint) -> c_int {
if seed.is_null() {
+4 -4
View File
@@ -13,8 +13,8 @@ use crate::{
platform::{
Pal, Sys,
types::{
blkcnt_t, blksize_t, c_char, c_int, dev_t, gid_t, ino_t, mode_t, nlink_t, off_t, uid_t,
useconds_t,
blkcnt_t, blksize_t, c_char, c_int, c_long, dev_t, gid_t, ino_t, mode_t, nlink_t,
off_t, uid_t,
},
},
};
@@ -52,8 +52,8 @@ pub const S_ISUID: c_int = 0o4_000;
pub const S_ISGID: c_int = 0o2_000;
pub const S_ISVTX: c_int = 0o1_000;
pub const UTIME_NOW: useconds_t = (1 << 30) - 1;
pub const UTIME_OMIT: useconds_t = (1 << 30) - 2;
pub const UTIME_NOW: c_long = (1 << 30) - 1;
pub const UTIME_OMIT: c_long = (1 << 30) - 2;
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_stat.h.html>.
#[repr(C)]
+3
View File
@@ -69,6 +69,7 @@ pub struct timezone {
/// The `getitimer()` function was marked obsolescent in the Open Group Base
/// Specifications Issue 7, and removed in Issue 8.
#[deprecated]
#[allow(deprecated)]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn getitimer(which: c_int, value: *mut itimerval) -> c_int {
Sys::getitimer(which, unsafe { &mut *value })
@@ -100,6 +101,7 @@ pub unsafe extern "C" fn gettimeofday(tp: *mut timeval, tzp: *mut timezone) -> c
/// The `setitimer()` function was marked obsolescent in the Open Group Base
/// Specifications Issue 7, and removed in Issue 8.
#[deprecated]
#[allow(deprecated)]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn setitimer(
which: c_int,
@@ -117,6 +119,7 @@ pub unsafe extern "C" fn setitimer(
/// # Deprecation
/// The `utimes()` function was marked legacy in the Open Group Base
/// Specifications Issue 6, and then unmarked in Issue 7.
#[deprecated]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn utimes(path: *const c_char, times: *const timeval) -> c_int {
let path = unsafe { CStr::from_ptr(path) };
+12 -5
View File
@@ -9,15 +9,15 @@
use core::ptr::NonNull;
#[allow(deprecated)]
use crate::header::sys_time::gettimeofday;
use crate::{
header::{
sys_select::timeval,
sys_time::{gettimeofday, timezone},
},
header::{sys_select::timeval, sys_time::timezone},
platform::types::{c_int, c_short, c_ushort, time_t},
};
/// See <https://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/timeb.h.html>.
#[deprecated]
#[repr(C)]
#[derive(Default)]
pub struct timeb {
@@ -32,6 +32,8 @@ pub struct timeb {
/// # Safety
/// The caller must ensure that `tp` is convertible to a `&mut
/// MaybeUninit<timeb>`.
#[deprecated]
#[allow(deprecated)]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn ftime(tp: *mut timeb) -> c_int {
// SAFETY: the caller is required to ensure that the pointer is valid.
@@ -42,10 +44,15 @@ pub unsafe extern "C" fn ftime(tp: *mut timeb) -> c_int {
// SAFETY: tv and tz are created above, and thus will coerce to valid
// pointers.
if unsafe { gettimeofday(&raw mut tv, &raw mut tz) } < 0 {
if unsafe {
#[allow(deprecated)]
gettimeofday(&raw mut tv, &raw mut tz)
} < 0
{
return -1;
}
#[allow(deprecated)]
tp_maybe_uninit.write(timeb {
time: tv.tv_sec,
millitm: (tv.tv_usec / 1000) as c_ushort,
+15 -4
View File
@@ -147,7 +147,10 @@ pub struct itimerspec {
#[deprecated]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn asctime(timeptr: *const tm) -> *mut c_char {
unsafe { asctime_r(timeptr, (&raw mut ASCTIME).cast()) }
unsafe {
#[allow(deprecated)]
asctime_r(timeptr, (&raw mut ASCTIME).cast())
}
}
/// See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/asctime.html>.
@@ -296,7 +299,10 @@ pub unsafe extern "C" fn clock_settime(clock_id: clockid_t, tp: *const timespec)
#[deprecated]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn ctime(clock: *const time_t) -> *mut c_char {
unsafe { asctime(localtime(clock)) }
unsafe {
#[allow(deprecated)]
asctime(localtime(clock))
}
}
/// See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/ctime.html>.
@@ -310,7 +316,10 @@ pub unsafe extern "C" fn ctime_r(clock: *const time_t, buf: *mut c_char) -> *mut
// Using MaybeUninit<tm> seems to cause a panic during the build process
let mut tm1 = blank_tm();
unsafe { localtime_r(clock, &raw mut tm1) };
unsafe { asctime_r(&raw const tm1, buf) }
unsafe {
#[allow(deprecated)]
asctime_r(&raw const tm1, buf)
}
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/difftime.html>.
@@ -760,7 +769,9 @@ fn time_zone() -> Tz {
fn now() -> NaiveDateTime {
let mut now = timespec::default();
if Sys::clock_gettime(CLOCK_REALTIME, Out::from_mut(&mut now)).is_ok() {}; // TODO what to do if Err?
NaiveDateTime::from_timestamp(now.tv_sec, now.tv_nsec as _)
DateTime::from_timestamp(now.tv_sec, now.tv_nsec as _)
.unwrap_or_default()
.naive_local()
}
#[inline(always)]
+10 -3
View File
@@ -9,6 +9,8 @@ use core::{
ptr, slice,
};
#[allow(deprecated)]
use crate::platform::types::useconds_t;
use crate::{
c_str::CStr,
error::{Errno, ResultExt},
@@ -27,18 +29,21 @@ use crate::{
self, ERRNO, Pal, PalSignal, 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,
size_t, ssize_t, suseconds_t, time_t, uid_t,
},
},
};
pub use self::{brk::*, getopt::*, getpass::getpass, pathconf::*, sysconf::*};
pub use self::{brk::*, getopt::*, pathconf::*, sysconf::*};
pub use crate::header::pthread::fork_hooks;
// Inclusion of ctermid() prototype marked as obsolescent since Issue 7, cf.
// <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html>.
// cuserid() marked legacy in Issue 5.
pub use crate::header::stdio::{ctermid, cuserid};
#[deprecated]
pub use crate::header::stdio::ctermid;
#[allow(deprecated)]
pub use crate::header::stdio::cuserid;
// TODO: implement and reexport fcntl functions:
//pub use crate::header::fcntl::{faccessat, fchownat, fexecve, linkat, readlinkat, symlinkat, unlinkat};
@@ -1115,6 +1120,7 @@ pub extern "C" fn ttyname_r(fildes: c_int, name: *mut c_char, namesize: size_t)
/// The `ualarm()` function was marked obsolescent in the Open Group Base
/// Specifications Issue 6, and removed in Issue 7.
#[deprecated]
#[allow(deprecated)]
#[unsafe(no_mangle)]
pub extern "C" fn ualarm(usecs: useconds_t, interval: useconds_t) -> useconds_t {
// TODO setitimer is unimplemented on Redox and obsolete
@@ -1164,6 +1170,7 @@ pub unsafe extern "C" fn unlinkat(fd: c_int, path: *const c_char, flags: c_int)
/// The `usleep()` function was marked obsolescent in the Open Group Base
/// Specifications Issue 6, and removed in Issue 7.
#[deprecated]
#[allow(deprecated)]
#[unsafe(no_mangle)]
pub extern "C" fn usleep(useconds: useconds_t) -> c_int {
#[cfg(not(target_arch = "x86"))]
+1
View File
@@ -26,6 +26,7 @@ pub struct utimbuf {
/// See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/utime.html>.
#[deprecated]
#[allow(deprecated)]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn utime(filename: *const c_char, times: *const utimbuf) -> c_int {
let filename_cstr = unsafe { CStr::from_ptr(filename) };
+1
View File
@@ -911,6 +911,7 @@ pub unsafe extern "C" fn wcstoull(
///
/// Marked legacy in issue 6.
/// Encouraged to use `wcsstr` instead, which this implementation simply forwards to.
#[deprecated]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn wcswcs(ws1: *const wchar_t, ws2: *const wchar_t) -> *mut wchar_t {
unsafe { wcsstr(ws1, ws2) }
-1
View File
@@ -219,7 +219,6 @@ struct Custom {
///
/// [`io::Error`]: struct.Error.html
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[allow(deprecated)]
#[non_exhaustive]
pub enum ErrorKind {
/// An entity was not found, often a file.
+42 -17
View File
@@ -6,22 +6,28 @@ use core::{
use super::{
super::{
PalSignal,
types::{c_int, c_uint, pid_t, time_t},
types::{c_int, c_uint, pid_t},
},
Sys, e_raw,
};
#[allow(deprecated)]
use crate::header::sys_time::itimerval;
use crate::{
error::{Errno, Result},
header::{
bits_timespec::timespec,
signal::{SA_RESTORER, SI_QUEUE, sigaction, siginfo_t, sigset_t, sigval, stack_t},
sys_select::timeval,
sys_time::{self, itimerval},
signal::{
SA_RESTORER, SI_QUEUE, SIGALRM, SIGEV_SIGNAL, sigaction, sigevent, siginfo_t, sigset_t,
sigval, stack_t,
},
time,
},
platform,
out::Out,
platform::{self, Pal, types::timer_t},
};
impl PalSignal for Sys {
#[allow(deprecated)]
fn getitimer(which: c_int, out: &mut itimerval) -> Result<()> {
unsafe {
e_raw(syscall!(GETITIMER, which, ptr::from_mut(out)))?;
@@ -58,6 +64,7 @@ impl PalSignal for Sys {
Ok(())
}
#[allow(deprecated)]
fn setitimer(which: c_int, new: &itimerval, old: Option<&mut itimerval>) -> Result<()> {
e_raw(unsafe {
syscall!(
@@ -72,22 +79,40 @@ impl PalSignal for Sys {
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/alarm.html>.
fn alarm(seconds: c_uint) -> c_uint {
let timer = itimerval {
it_value: timeval {
tv_sec: time_t::from(seconds),
tv_usec: 0,
},
..Default::default()
let mut signal_event = sigevent {
sigev_value: sigval { sival_int: 0 },
sigev_signo: SIGALRM as c_int,
sigev_notify: SIGEV_SIGNAL,
sigev_notify_attributes: ptr::null_mut(),
sigev_notify_function: None,
};
let mut otimer = itimerval::default();
let mut timerid: timer_t = Default::default();
let timer = unsafe {
time::timer_create(
time::CLOCK_REALTIME,
ptr::from_mut(&mut signal_event),
ptr::from_mut(&mut timerid),
)
};
let value = time::itimerspec {
it_value: timespec {
tv_sec: i64::from(seconds),
tv_nsec: 0,
},
it_interval: timespec {
tv_sec: 0,
tv_nsec: 0,
},
};
let mut ovalue = Default::default();
let errno_backup = platform::ERRNO.get();
let secs = if Self::setitimer(sys_time::ITIMER_REAL, &timer, Some(&mut otimer)).is_err() {
if Sys::timer_settime(timerid, 0, &value, Some(Out::from_mut(&mut ovalue))).is_err() {
platform::ERRNO.set(errno_backup);
0
} else {
otimer.it_value.tv_sec as c_uint + if otimer.it_value.tv_usec > 0 { 1 } else { 0 }
};
platform::ERRNO.set(errno_backup);
secs
ovalue.it_value.tv_sec as c_uint + if ovalue.it_value.tv_nsec > 0 { 1 } else { 0 }
}
}
fn sigaction(
+4 -1
View File
@@ -2,18 +2,20 @@ use super::super::{
Pal,
types::{c_int, c_uint, pid_t},
};
#[allow(deprecated)]
use crate::header::sys_time::itimerval;
use crate::{
error::{Errno, Result},
header::{
bits_timespec::timespec,
signal::{sigaction, siginfo_t, sigset_t, sigval, stack_t},
sys_time::itimerval,
},
};
/// Platform abstraction of signal-related functionality.
pub trait PalSignal: Pal {
/// Platform implementation of [`getitimer()`](crate::header::sys_time::getitimer) from [`sys/time.h`](crate::header::sys_time).
#[allow(deprecated)]
fn getitimer(which: c_int, out: &mut itimerval) -> Result<()>;
/// Platform implementation of [`kill()`](crate::header::signal::kill) from [`signal.h`](crate::header::signal).
@@ -29,6 +31,7 @@ pub trait PalSignal: Pal {
fn raise(sig: c_int) -> Result<()>;
/// Platform implementation of [`setitimer()`](crate::header::sys_time::setitimer) from [`sys/time.h`](crate::header::sys_time).
#[allow(deprecated)]
fn setitimer(which: c_int, new: &itimerval, old: Option<&mut itimerval>) -> Result<()>;
/// Platform implementation of [`alarm()`](crate::header::unistd::alarm) from [`unistd.h`](crate::header::unistd).
+4 -1
View File
@@ -2,6 +2,8 @@ use super::{
super::{Pal, PalSignal, types::*},
Sys,
};
#[allow(deprecated)]
use crate::header::sys_time::{ITIMER_REAL, itimerval};
use crate::{
error::{Errno, Result},
header::{
@@ -12,7 +14,6 @@ use crate::{
SS_DISABLE, SS_ONSTACK, sigaction, sigevent, siginfo_t, sigset_t, sigval, stack_t,
ucontext_t,
},
sys_time::{ITIMER_REAL, itimerval},
time::{itimerspec, timer_internal_t},
},
out::Out,
@@ -58,6 +59,7 @@ const _: () = {
};
impl PalSignal for Sys {
#[allow(deprecated)]
fn getitimer(which: c_int, out: &mut itimerval) -> Result<()> {
let path = match which {
ITIMER_REAL => "/scheme/itimer/1",
@@ -100,6 +102,7 @@ impl PalSignal for Sys {
unsafe { Self::rlct_kill(Self::current_os_tid(), sig as _) }
}
#[allow(deprecated)]
fn setitimer(which: c_int, _new: &itimerval, old: Option<&mut itimerval>) -> Result<()> {
// TODO: setitimer is no longer part of POSIX and should not be implemented in Redox
// Change the platform-independent implementation to use POSIX timers.
+3 -2
View File
@@ -27,10 +27,11 @@ use crate::{
platform::{Pal, Sys, types::c_int},
};
use core::{
hint,
mem::MaybeUninit,
ops::Deref,
ptr,
sync::atomic::{self, AtomicI32, AtomicI32 as AtomicInt, AtomicU32},
sync::atomic::{AtomicI32, AtomicI32 as AtomicInt, AtomicU32},
};
const FUTEX_WAIT: c_int = 0;
@@ -154,7 +155,7 @@ where
{
// First, try spinning for really short durations
for _ in 0..999 {
atomic::spin_loop_hint();
hint::spin_loop();
if attempt(word) == AttemptStatus::Desired {
return;
}