Skip to content

Address multiple CI failures #2642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ targets = [
]

[dependencies]
libc = { version = "0.2.171", features = ["extra_traits"] }
libc = { version = "=0.2.172", features = ["extra_traits"] }
bitflags = "2.3.3"
cfg-if = "1.0"
pin-utils = { version = "0.1.0", optional = true }
Expand Down
8 changes: 8 additions & 0 deletions changelog/2642.removed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Removed `Eq` and `PartialEq` implementations from `SigHandler`, because they
never worked reliably. The suggested alternative is `matches!`. For example:
```
let h: SigHandler = ...
if matches!(h, SigHandler::SigIgn) {
...
}
```
4 changes: 2 additions & 2 deletions src/dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl Dir {
}

/// Returns an iterator of `Result<Entry>` which rewinds when finished.
pub fn iter(&mut self) -> Iter {
pub fn iter(&mut self) -> Iter<'_> {
Iter(self)
}
}
Expand All @@ -133,7 +133,7 @@ impl Dir {
unsafe impl Send for Dir {}

impl std::os::fd::AsFd for Dir {
fn as_fd(&self) -> std::os::fd::BorrowedFd {
fn as_fd(&self) -> std::os::fd::BorrowedFd<'_> {
let raw_fd = self.as_raw_fd();

// SAFETY:
Expand Down
4 changes: 2 additions & 2 deletions src/fcntl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,15 +745,15 @@ pub enum FcntlArg<'a> {
F_SETFL(OFlag), // O_NONBLOCK
/// Set or clear a file segment lock
F_SETLK(&'a libc::flock),
/// Like [`F_SETLK`](FcntlArg::F_SETLK) except that if a shared or exclusive lock is blocked by
/// Like [`F_SETLK`] except that if a shared or exclusive lock is blocked by
/// other locks, the process waits until the request can be satisfied.
F_SETLKW(&'a libc::flock),
/// Get the first lock that blocks the lock description
F_GETLK(&'a mut libc::flock),
/// Acquire or release an open file description lock
#[cfg(linux_android)]
F_OFD_SETLK(&'a libc::flock),
/// Like [`F_OFD_SETLK`](FcntlArg::F_OFD_SETLK) except that if a conflicting lock is held on
/// Like [`F_OFD_SETLK`] except that if a conflicting lock is held on
/// the file, then wait for that lock to be released.
#[cfg(linux_android)]
F_OFD_SETLKW(&'a libc::flock),
Expand Down
2 changes: 1 addition & 1 deletion src/mqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ pub fn mq_remove_nonblock(mqd: &MqdT) -> Result<MqAttr> {
#[cfg(any(target_os = "linux", target_os = "netbsd", target_os = "dragonfly"))]
impl AsFd for MqdT {
/// Borrow the underlying message queue descriptor.
fn as_fd(&self) -> BorrowedFd {
fn as_fd(&self) -> BorrowedFd<'_> {
// SAFETY: [MqdT] will only contain a valid fd by construction.
unsafe { BorrowedFd::borrow_raw(self.0) }
}
Expand Down
13 changes: 8 additions & 5 deletions src/sys/aio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
//! [`cancel`](trait.Aio.html#method.cancel) or
//! [`aio_cancel_all`](fn.aio_cancel_all.html), though the operating system may
//! not support this for all filesystems and devices.
#![allow(clippy::doc_overindented_list_items)] // It looks better this way
#[cfg(target_os = "freebsd")]
use std::io::{IoSlice, IoSliceMut};
use std::{
Expand Down Expand Up @@ -313,7 +314,7 @@ pub trait Aio {
fn error(self: Pin<&mut Self>) -> Result<()>;

/// Returns the underlying file descriptor associated with the operation.
fn fd(&self) -> BorrowedFd;
fn fd(&self) -> BorrowedFd<'_>;

/// Does this operation currently have any in-kernel state?
///
Expand Down Expand Up @@ -572,8 +573,9 @@ impl<'a> AioRead<'a> {
/// * `fd`: File descriptor to read from
/// * `offs`: File offset
/// * `buf`: A memory buffer. It must outlive the `AioRead`.
/// * `prio`: If POSIX Prioritized IO is supported, then the operation
/// will be prioritized at the process's priority level minus `prio`
/// * `prio`: If POSIX Prioritized IO is supported, then the
/// operation will be prioritized at the process's
/// priority level minus `prio`.
/// * `sigev_notify`: Determines how you will be notified of event completion.
pub fn new(
fd: BorrowedFd<'a>,
Expand Down Expand Up @@ -802,8 +804,9 @@ impl<'a> AioWrite<'a> {
/// * `fd`: File descriptor to write to
/// * `offs`: File offset
/// * `buf`: A memory buffer. It must outlive the `AioWrite`.
/// * `prio`: If POSIX Prioritized IO is supported, then the operation
/// will be prioritized at the process's priority level minus `prio`
/// * `prio`: If POSIX Prioritized IO is supported, then the
/// operation will be prioritized at the process's
/// priority level minus `prio`
/// * `sigev_notify`: Determines how you will be notified of event completion.
pub fn new(
fd: BorrowedFd<'a>,
Expand Down
2 changes: 1 addition & 1 deletion src/sys/eventfd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl EventFd {
}
}
impl AsFd for EventFd {
fn as_fd(&self) -> BorrowedFd {
fn as_fd(&self) -> BorrowedFd<'_> {
self.0.as_fd()
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/sys/fanotify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ impl FanotifyEvent {
/// The file descriptor of the event. If the value is `None` when reading
/// from the fanotify group, this event is to notify that a group queue
/// overflow occured.
pub fn fd(&self) -> Option<BorrowedFd> {
pub fn fd(&self) -> Option<BorrowedFd<'_>> {
if self.0.fd == libc::FAN_NOFD {
None
} else {
Expand Down Expand Up @@ -443,4 +443,4 @@ impl Fanotify {
fd
}
}
}
}
2 changes: 1 addition & 1 deletion src/sys/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl<'fd> FdSet<'fd> {
/// assert_eq!(fds, vec![4, 9]);
/// ```
#[inline]
pub fn fds(&self, highest: Option<RawFd>) -> Fds {
pub fn fds(&self, highest: Option<RawFd>) -> Fds<'_, '_> {
Fds {
set: self,
range: 0..highest.map(|h| h as usize + 1).unwrap_or(FD_SETSIZE),
Expand Down
4 changes: 2 additions & 2 deletions src/sys/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ impl<'a> IntoIterator for &'a SigSet {
}

/// A signal handler.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[derive(Clone, Copy, Debug, Hash)]
pub enum SigHandler {
/// Default signal handling.
SigDfl,
Expand Down Expand Up @@ -1035,7 +1035,7 @@ pub fn sigprocmask(how: SigmaskHow, set: Option<&SigSet>, oldset: Option<&mut Si
/// - If less than `-1`, the signal is sent to all processes whose
/// process group ID is equal to the absolute value of `pid`.
/// * `signal` - Signal to send. If `None`, error checking is performed
/// but no signal is actually sent.
/// but no signal is actually sent.
///
/// See Also
/// [`kill(2)`](https://pubs.opengroup.org/onlinepubs/9699919799/functions/kill.html)
Expand Down
2 changes: 1 addition & 1 deletion src/sys/signalfd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl SignalFd {
}

impl AsFd for SignalFd {
fn as_fd(&self) -> BorrowedFd {
fn as_fd(&self) -> BorrowedFd<'_> {
self.0.as_fd()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/sys/socket/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ impl<S> RecvMsg<'_, '_, S> {
/// Iterate over the valid control messages pointed to by this msghdr. If
/// allocated space for CMSGs was too small it is not safe to iterate,
/// instead return an `Error::ENOBUFS` error.
pub fn cmsgs(&self) -> Result<CmsgIterator> {
pub fn cmsgs(&self) -> Result<CmsgIterator<'_>> {

if self.mhdr.msg_flags & MSG_CTRUNC == MSG_CTRUNC {
return Err(Errno::ENOBUFS);
Expand Down
2 changes: 1 addition & 1 deletion src/sys/socket/sockopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1955,7 +1955,7 @@ pub struct SetOsString<'a> {

#[cfg(any(target_os = "freebsd", linux_android, target_os = "illumos"))]
impl<'a> Set<'a, OsString> for SetOsString<'a> {
fn new(val: &OsString) -> SetOsString {
fn new(val: &OsString) -> SetOsString<'_> {
SetOsString {
val: val.as_os_str(),
}
Expand Down
2 changes: 1 addition & 1 deletion src/sys/termios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl Termios {
///
/// This is not part of `nix`'s public API because it requires additional work to maintain type
/// safety.
pub(crate) fn get_libc_termios(&self) -> Ref<libc::termios> {
pub(crate) fn get_libc_termios(&self) -> Ref<'_, libc::termios> {
{
let mut termios = self.inner.borrow_mut();
termios.c_iflag = self.input_flags.bits();
Expand Down
31 changes: 11 additions & 20 deletions test/sys/test_signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,32 +112,23 @@ fn test_signal() {

unsafe { signal(Signal::SIGINT, SigHandler::SigIgn) }.unwrap();
raise(Signal::SIGINT).unwrap();
assert_eq!(
unsafe { signal(Signal::SIGINT, SigHandler::SigDfl) }.unwrap(),
SigHandler::SigIgn
);
let h = unsafe { signal(Signal::SIGINT, SigHandler::SigDfl) }.unwrap();
assert!(matches!(h, SigHandler::SigIgn));

let handler = SigHandler::Handler(test_sigaction_handler);
assert_eq!(
unsafe { signal(Signal::SIGINT, handler) }.unwrap(),
SigHandler::SigDfl
);
let h = unsafe { signal(Signal::SIGINT, handler) }.unwrap();
assert!(matches!(h, SigHandler::SigDfl));
raise(Signal::SIGINT).unwrap();
assert!(SIGNALED.load(Ordering::Relaxed));

let h = unsafe { signal(Signal::SIGINT, SigHandler::SigDfl) }.unwrap();
#[cfg(not(solarish))]
assert_eq!(
unsafe { signal(Signal::SIGINT, SigHandler::SigDfl) }.unwrap(),
handler
);
assert!(matches!(h, SigHandler::Handler(_)));

// System V based OSes (e.g. illumos and Solaris) always resets the
// disposition to SIG_DFL prior to calling the signal handler
#[cfg(solarish)]
assert_eq!(
unsafe { signal(Signal::SIGINT, SigHandler::SigDfl) }.unwrap(),
SigHandler::SigDfl
);
assert!(matches!(h, SigHandler::SigDfl));

// Restore default signal handler
unsafe { signal(Signal::SIGINT, SigHandler::SigDfl) }.unwrap();
Expand Down Expand Up @@ -307,21 +298,21 @@ fn test_sigaction() {
action_sig.flags(),
SaFlags::SA_ONSTACK | SaFlags::SA_RESTART
);
assert_eq!(action_sig.handler(), handler_sig);
assert!(matches!(action_sig.handler(), SigHandler::Handler(_)));

mask = action_sig.mask();
assert!(mask.contains(SIGUSR1));
assert!(!mask.contains(SIGUSR2));

let handler_act = SigHandler::SigAction(test_sigaction_action);
let action_act = SigAction::new(handler_act, flags, mask);
assert_eq!(action_act.handler(), handler_act);
assert!(matches!(action_act.handler(), SigHandler::SigAction(_)));

let action_dfl = SigAction::new(SigHandler::SigDfl, flags, mask);
assert_eq!(action_dfl.handler(), SigHandler::SigDfl);
assert!(matches!(action_dfl.handler(), SigHandler::SigDfl));

let action_ign = SigAction::new(SigHandler::SigIgn, flags, mask);
assert_eq!(action_ign.handler(), SigHandler::SigIgn);
assert!(matches!(action_ign.handler(), SigHandler::SigIgn));
})
.join()
.unwrap();
Expand Down
15 changes: 8 additions & 7 deletions test/test_fcntl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,13 +541,14 @@ mod test_posix_fallocate {
assert_eq!(tmp.read(&mut data).expect("read failure"), LEN);
assert_eq!(&data[..], &[0u8; LEN][..]);
}
Err(Errno::EINVAL) => {
// POSIX requires posix_fallocate to return EINVAL both for
// invalid arguments (i.e. len < 0) and if the operation is not
// supported by the file system.
// There's no way to tell for sure whether the file system
// supports posix_fallocate, so we must pass the test if it
// returns EINVAL.
Err(Errno::ENOTSUP) | Err(Errno::EINVAL) => {
// POSIX 1003.1-2024 Issue 8 specified ENOTSUP for "the file
// system does not support this operation", so Nix should accept
// that error code and pass the test.
// But older POSIX required posix_fallocate to return EINVAL
// both for invalid arguments (i.e. len < 0) and if the
// operation is not supported by the file system. So we must
// also pass the test if it returns EINVAL.
}
_ => res.unwrap(),
}
Expand Down