mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
Merge pull request #8018 from Ecordonnier/eco/musl-utmpx-warnings
utmpx: silence musl warnings
This commit is contained in:
commit
d3f5f3aaa7
1 changed files with 13 additions and 0 deletions
|
@ -40,11 +40,19 @@ use std::ptr;
|
||||||
use std::sync::{Mutex, MutexGuard};
|
use std::sync::{Mutex, MutexGuard};
|
||||||
|
|
||||||
pub use self::ut::*;
|
pub use self::ut::*;
|
||||||
|
|
||||||
|
// See the FAQ at https://wiki.musl-libc.org/faq#Q:-Why-is-the-utmp/wtmp-functionality-only-implemented-as-stubs?
|
||||||
|
// Musl implements only stubs for the utmp functions, and the libc crate issues a deprecation warning about this.
|
||||||
|
// However, calling these stubs is the correct approach to maintain consistent behavior with GNU coreutils.
|
||||||
|
#[cfg_attr(target_env = "musl", allow(deprecated))]
|
||||||
pub use libc::endutxent;
|
pub use libc::endutxent;
|
||||||
|
#[cfg_attr(target_env = "musl", allow(deprecated))]
|
||||||
pub use libc::getutxent;
|
pub use libc::getutxent;
|
||||||
|
#[cfg_attr(target_env = "musl", allow(deprecated))]
|
||||||
pub use libc::setutxent;
|
pub use libc::setutxent;
|
||||||
use libc::utmpx;
|
use libc::utmpx;
|
||||||
#[cfg(any(target_vendor = "apple", target_os = "linux", target_os = "netbsd"))]
|
#[cfg(any(target_vendor = "apple", target_os = "linux", target_os = "netbsd"))]
|
||||||
|
#[cfg_attr(target_env = "musl", allow(deprecated))]
|
||||||
pub use libc::utmpxname;
|
pub use libc::utmpxname;
|
||||||
|
|
||||||
/// # Safety
|
/// # Safety
|
||||||
|
@ -278,6 +286,7 @@ impl Utmpx {
|
||||||
// This can technically fail, and it would be nice to detect that,
|
// This can technically fail, and it would be nice to detect that,
|
||||||
// but it doesn't return anything so we'd have to do nasty things
|
// but it doesn't return anything so we'd have to do nasty things
|
||||||
// with errno.
|
// with errno.
|
||||||
|
#[cfg_attr(target_env = "musl", allow(deprecated))]
|
||||||
setutxent();
|
setutxent();
|
||||||
}
|
}
|
||||||
iter
|
iter
|
||||||
|
@ -302,7 +311,9 @@ impl Utmpx {
|
||||||
// is specified, no warning or anything.
|
// is specified, no warning or anything.
|
||||||
// So this function is pretty crazy and we don't try to detect errors.
|
// So this function is pretty crazy and we don't try to detect errors.
|
||||||
// Not much we can do besides pray.
|
// Not much we can do besides pray.
|
||||||
|
#[cfg_attr(target_env = "musl", allow(deprecated))]
|
||||||
utmpxname(path.as_ptr());
|
utmpxname(path.as_ptr());
|
||||||
|
#[cfg_attr(target_env = "musl", allow(deprecated))]
|
||||||
setutxent();
|
setutxent();
|
||||||
}
|
}
|
||||||
iter
|
iter
|
||||||
|
@ -342,6 +353,7 @@ impl Iterator for UtmpxIter {
|
||||||
type Item = Utmpx;
|
type Item = Utmpx;
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
#[cfg_attr(target_env = "musl", allow(deprecated))]
|
||||||
let res = getutxent();
|
let res = getutxent();
|
||||||
if res.is_null() {
|
if res.is_null() {
|
||||||
None
|
None
|
||||||
|
@ -361,6 +373,7 @@ impl Iterator for UtmpxIter {
|
||||||
impl Drop for UtmpxIter {
|
impl Drop for UtmpxIter {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
#[cfg_attr(target_env = "musl", allow(deprecated))]
|
||||||
endutxent();
|
endutxent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue