Skip to content
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

Remove deprecated items #1785

Merged
merged 5 commits into from Aug 12, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/sched.rs
Expand Up @@ -233,8 +233,8 @@ mod sched_affinity {
/// use nix::unistd::Pid;
///
/// let mut cpu_set = CpuSet::new();
/// cpu_set.set(0);
/// sched_setaffinity(Pid::from_raw(0), &cpu_set);
/// cpu_set.set(0).unwrap();
/// sched_setaffinity(Pid::from_raw(0), &cpu_set).unwrap();
/// ```
pub fn sched_setaffinity(pid: Pid, cpuset: &CpuSet) -> Result<()> {
let res = unsafe {
Expand Down
2 changes: 1 addition & 1 deletion src/sys/personality.rs
Expand Up @@ -86,7 +86,7 @@ pub fn get() -> Result<Persona> {
/// # use nix::sys::personality::{self, Persona};
/// let mut pers = personality::get().unwrap();
/// assert!(!pers.contains(Persona::ADDR_NO_RANDOMIZE));
/// personality::set(pers | Persona::ADDR_NO_RANDOMIZE);
/// personality::set(pers | Persona::ADDR_NO_RANDOMIZE).unwrap();
/// ```
pub fn set(persona: Persona) -> Result<Persona> {
let res = unsafe {
Expand Down
4 changes: 2 additions & 2 deletions src/sys/quota.rs
Expand Up @@ -6,11 +6,11 @@
//!
//! ```rust,no_run
//! # use nix::sys::quota::{Dqblk, quotactl_on, quotactl_set, QuotaFmt, QuotaType, QuotaValidFlags};
//! quotactl_on(QuotaType::USRQUOTA, "/dev/sda1", QuotaFmt::QFMT_VFS_V1, "aquota.user");
//! quotactl_on(QuotaType::USRQUOTA, "/dev/sda1", QuotaFmt::QFMT_VFS_V1, "aquota.user").unwrap();
//! let mut dqblk: Dqblk = Default::default();
//! dqblk.set_blocks_hard_limit(10000);
//! dqblk.set_blocks_soft_limit(8000);
//! quotactl_set(QuotaType::USRQUOTA, "/dev/sda1", 50, &dqblk, QuotaValidFlags::QIF_BLIMITS);
//! quotactl_set(QuotaType::USRQUOTA, "/dev/sda1", 50, &dqblk, QuotaValidFlags::QIF_BLIMITS).unwrap();
//! ```
use std::default::Default;
use std::{mem, ptr};
Expand Down
2 changes: 1 addition & 1 deletion src/sys/socket/mod.rs
Expand Up @@ -677,7 +677,7 @@ pub enum ControlMessageOwned {
/// None).unwrap();
/// setsockopt(in_socket, sockopt::ReceiveTimestamp, &true).unwrap();
/// let localhost = SockaddrIn::from_str("127.0.0.1:0").unwrap();
/// bind(in_socket, &localhost);
/// bind(in_socket, &localhost).unwrap();
/// let address: SockaddrIn = getsockname(in_socket).unwrap();
/// // Get initial time
/// let time0 = SystemTime::now();
Expand Down
2 changes: 1 addition & 1 deletion src/sys/socket/sockopt.rs
Expand Up @@ -982,7 +982,7 @@ mod test {
let a_cred = getsockopt(a, super::PeerCredentials).unwrap();
let b_cred = getsockopt(b, super::PeerCredentials).unwrap();
assert_eq!(a_cred, b_cred);
assert!(a_cred.pid() != 0);
assert_ne!(a_cred.pid(), 0);
}

#[test]
Expand Down
10 changes: 5 additions & 5 deletions src/sys/termios.rs
Expand Up @@ -64,9 +64,9 @@
//! # use nix::sys::termios::{BaudRate, cfsetispeed, cfsetospeed, cfsetspeed, Termios};
//! # fn main() {
//! # let mut t: Termios = unsafe { std::mem::zeroed() };
//! cfsetispeed(&mut t, BaudRate::B9600);
//! cfsetospeed(&mut t, BaudRate::B9600);
//! cfsetspeed(&mut t, BaudRate::B9600);
//! cfsetispeed(&mut t, BaudRate::B9600).unwrap();
//! cfsetospeed(&mut t, BaudRate::B9600).unwrap();
//! cfsetspeed(&mut t, BaudRate::B9600).unwrap();
//! # }
//! ```
//!
Expand All @@ -76,10 +76,10 @@
//! # use nix::sys::termios::{BaudRate, cfgetispeed, cfgetospeed, cfsetispeed, cfsetspeed, Termios};
//! # fn main() {
//! # let mut t: Termios = unsafe { std::mem::zeroed() };
//! # cfsetspeed(&mut t, BaudRate::B9600);
//! # cfsetspeed(&mut t, BaudRate::B9600).unwrap();
//! let speed = cfgetispeed(&t);
//! assert_eq!(speed, cfgetospeed(&t));
//! cfsetispeed(&mut t, speed);
//! cfsetispeed(&mut t, speed).unwrap();
//! # }
//! ```
//!
Expand Down
16 changes: 8 additions & 8 deletions src/sys/time.rs
Expand Up @@ -193,10 +193,10 @@ const SECS_PER_MINUTE: i64 = 60;
const SECS_PER_HOUR: i64 = 3600;

#[cfg(target_pointer_width = "64")]
const TS_MAX_SECONDS: i64 = (::std::i64::MAX / NANOS_PER_SEC) - 1;
const TS_MAX_SECONDS: i64 = (i64::MAX / NANOS_PER_SEC) - 1;

#[cfg(target_pointer_width = "32")]
const TS_MAX_SECONDS: i64 = ::std::isize::MAX as i64;
const TS_MAX_SECONDS: i64 = isize::MAX as i64;

const TS_MIN_SECONDS: i64 = -TS_MAX_SECONDS;

Expand Down Expand Up @@ -453,10 +453,10 @@ pub struct TimeVal(timeval);
const MICROS_PER_SEC: i64 = 1_000_000;

#[cfg(target_pointer_width = "64")]
const TV_MAX_SECONDS: i64 = (::std::i64::MAX / MICROS_PER_SEC) - 1;
const TV_MAX_SECONDS: i64 = (i64::MAX / MICROS_PER_SEC) - 1;

#[cfg(target_pointer_width = "32")]
const TV_MAX_SECONDS: i64 = ::std::isize::MAX as i64;
const TV_MAX_SECONDS: i64 = isize::MAX as i64;

const TV_MIN_SECONDS: i64 = -TV_MAX_SECONDS;

Expand Down Expand Up @@ -713,7 +713,7 @@ mod test {

#[test]
pub fn test_timespec() {
assert!(TimeSpec::seconds(1) != TimeSpec::zero());
assert_ne!(TimeSpec::seconds(1), TimeSpec::zero());
assert_eq!(
TimeSpec::seconds(1) + TimeSpec::seconds(2),
TimeSpec::seconds(3)
Expand Down Expand Up @@ -743,7 +743,7 @@ mod test {

#[test]
pub fn test_timespec_ord() {
assert!(TimeSpec::seconds(1) == TimeSpec::nanoseconds(1_000_000_000));
assert_eq!(TimeSpec::seconds(1), TimeSpec::nanoseconds(1_000_000_000));
assert!(TimeSpec::seconds(1) < TimeSpec::nanoseconds(1_000_000_001));
assert!(TimeSpec::seconds(1) > TimeSpec::nanoseconds(999_999_999));
assert!(TimeSpec::seconds(-1) < TimeSpec::nanoseconds(-999_999_999));
Expand All @@ -765,7 +765,7 @@ mod test {

#[test]
pub fn test_timeval() {
assert!(TimeVal::seconds(1) != TimeVal::zero());
assert_ne!(TimeVal::seconds(1), TimeVal::zero());
assert_eq!(
TimeVal::seconds(1) + TimeVal::seconds(2),
TimeVal::seconds(3)
Expand All @@ -778,7 +778,7 @@ mod test {

#[test]
pub fn test_timeval_ord() {
assert!(TimeVal::seconds(1) == TimeVal::microseconds(1_000_000));
assert_eq!(TimeVal::seconds(1), TimeVal::microseconds(1_000_000));
assert!(TimeVal::seconds(1) < TimeVal::microseconds(1_000_001));
assert!(TimeVal::seconds(1) > TimeVal::microseconds(999_999));
assert!(TimeVal::seconds(-1) < TimeVal::microseconds(-999_999));
Expand Down
8 changes: 4 additions & 4 deletions src/unistd.rs
Expand Up @@ -1572,7 +1572,7 @@ pub fn getgroups() -> Result<Vec<Gid>> {
/// # use std::error::Error;
/// # use nix::unistd::*;
/// #
/// # fn try_main() -> Result<(), Box<Error>> {
/// # fn try_main() -> Result<(), Box<dyn Error>> {
/// let uid = Uid::from_raw(33);
/// let gid = Gid::from_raw(34);
/// setgroups(&[gid])?;
Expand Down Expand Up @@ -1698,7 +1698,7 @@ pub fn getgrouplist(user: &CStr, group: Gid) -> Result<Vec<Gid>> {
/// # use std::ffi::CString;
/// # use nix::unistd::*;
/// #
/// # fn try_main() -> Result<(), Box<Error>> {
/// # fn try_main() -> Result<(), Box<dyn Error>> {
/// let user = CString::new("www-data").unwrap();
/// let uid = Uid::from_raw(33);
/// let gid = Gid::from_raw(33);
Expand Down Expand Up @@ -3121,7 +3121,7 @@ impl User {
/// use nix::unistd::{Uid, User};
/// // Returns an Result<Option<User>>, thus the double unwrap.
/// let res = User::from_uid(Uid::from_raw(0)).unwrap().unwrap();
/// assert!(res.name == "root");
/// assert_eq!(res.name, "root");
/// ```
pub fn from_uid(uid: Uid) -> Result<Option<Self>> {
User::from_anything(|pwd, cbuf, cap, res| {
Expand All @@ -3140,7 +3140,7 @@ impl User {
/// use nix::unistd::User;
/// // Returns an Result<Option<User>>, thus the double unwrap.
/// let res = User::from_name("root").unwrap().unwrap();
/// assert!(res.name == "root");
/// assert_eq!(res.name, "root");
/// ```
pub fn from_name(name: &str) -> Result<Option<Self>> {
let name = CString::new(name).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion test/sys/test_pthread.rs
Expand Up @@ -11,7 +11,7 @@ fn test_pthread_self() {
#[test]
fn test_pthread_self() {
let tid = pthread_self();
assert!(tid != 0);
assert_ne!(tid, 0);
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions test/sys/test_ptrace.rs
Expand Up @@ -33,7 +33,7 @@ fn test_ptrace_setoptions() {
require_capability!("test_ptrace_setoptions", CAP_SYS_PTRACE);
let err = ptrace::setoptions(getpid(), Options::PTRACE_O_TRACESYSGOOD)
.unwrap_err();
assert!(err != Errno::EOPNOTSUPP);
assert_ne!(err, Errno::EOPNOTSUPP);
}

// Just make sure ptrace_getevent can be called at all, for now.
Expand All @@ -42,7 +42,7 @@ fn test_ptrace_setoptions() {
fn test_ptrace_getevent() {
require_capability!("test_ptrace_getevent", CAP_SYS_PTRACE);
let err = ptrace::getevent(getpid()).unwrap_err();
assert!(err != Errno::EOPNOTSUPP);
assert_ne!(err, Errno::EOPNOTSUPP);
}

// Just make sure ptrace_getsiginfo can be called at all, for now.
Expand Down
2 changes: 1 addition & 1 deletion test/test_dir.rs
Expand Up @@ -20,7 +20,7 @@ fn flags() -> OFlag {
fn read() {
let tmp = tempdir().unwrap();
File::create(&tmp.path().join("foo")).unwrap();
::std::os::unix::fs::symlink("foo", tmp.path().join("bar")).unwrap();
std::os::unix::fs::symlink("foo", tmp.path().join("bar")).unwrap();
let mut dir = Dir::open(tmp.path(), flags(), Mode::empty()).unwrap();
let mut entries: Vec<_> = dir.iter().map(|e| e.unwrap()).collect();
entries.sort_by(|a, b| a.file_name().cmp(b.file_name()));
Expand Down
6 changes: 3 additions & 3 deletions test/test_pty.rs
Expand Up @@ -58,7 +58,7 @@ fn test_ptsname_copy() {
assert_eq!(slave_name1, slave_name2);
// Also make sure that the string was actually copied and they point to different parts of
// memory.
assert!(slave_name1.as_ptr() != slave_name2.as_ptr());
assert_ne!(slave_name1.as_ptr(), slave_name2.as_ptr());
}

/// Test data copying of `ptsname_r`
Expand All @@ -73,7 +73,7 @@ fn test_ptsname_r_copy() {
let slave_name1 = ptsname_r(&master_fd).unwrap();
let slave_name2 = ptsname_r(&master_fd).unwrap();
assert_eq!(slave_name1, slave_name2);
assert!(slave_name1.as_ptr() != slave_name2.as_ptr());
assert_ne!(slave_name1.as_ptr(), slave_name2.as_ptr());
}

/// Test that `ptsname` returns different names for different devices
Expand All @@ -93,7 +93,7 @@ fn test_ptsname_unique() {
// Get the name of the slave
let slave_name1 = unsafe { ptsname(&master1_fd) }.unwrap();
let slave_name2 = unsafe { ptsname(&master2_fd) }.unwrap();
assert!(slave_name1 != slave_name2);
assert_ne!(slave_name1, slave_name2);
}

/// Common setup for testing PTTY pairs
Expand Down
8 changes: 4 additions & 4 deletions test/test_stat.rs
Expand Up @@ -378,8 +378,8 @@ fn test_mknod() {
let target = tempdir.path().join(file_name);
mknod(&target, SFlag::S_IFREG, Mode::S_IRWXU, 0).unwrap();
let mode = lstat(&target).unwrap().st_mode as mode_t;
assert!(mode & libc::S_IFREG == libc::S_IFREG);
assert!(mode & libc::S_IRWXU == libc::S_IRWXU);
assert_eq!(mode & libc::S_IFREG, libc::S_IFREG);
assert_eq!(mode & libc::S_IRWXU, libc::S_IRWXU);
}

#[test]
Expand Down Expand Up @@ -416,6 +416,6 @@ fn test_mknodat() {
)
.unwrap()
.st_mode as mode_t;
assert!(mode & libc::S_IFREG == libc::S_IFREG);
assert!(mode & libc::S_IRWXU == libc::S_IRWXU);
assert_eq!(mode & libc::S_IFREG, libc::S_IFREG);
assert_eq!(mode & libc::S_IRWXU, libc::S_IRWXU);
}
22 changes: 11 additions & 11 deletions test/test_unistd.rs
Expand Up @@ -114,7 +114,7 @@ fn test_mkfifo() {

let stats = stat::stat(&mkfifo_fifo).unwrap();
let typ = stat::SFlag::from_bits_truncate(stats.st_mode as mode_t);
assert!(typ == SFlag::S_IFIFO);
assert_eq!(typ, SFlag::S_IFIFO);
}

#[test]
Expand Down Expand Up @@ -300,7 +300,7 @@ fn test_initgroups() {
}

#[cfg(not(any(target_os = "fuchsia", target_os = "redox")))]
macro_rules! execve_test_factory(
macro_rules! execve_test_factory (
($test_name:ident, $syscall:ident, $exe: expr $(, $pathname:expr, $flags:expr)*) => (

#[cfg(test)]
Expand Down Expand Up @@ -694,9 +694,9 @@ fn test_sysconf_unsupported() {
#[test]
fn test_getresuid() {
let resuids = getresuid().unwrap();
assert!(resuids.real.as_raw() != libc::uid_t::max_value());
assert!(resuids.effective.as_raw() != libc::uid_t::max_value());
assert!(resuids.saved.as_raw() != libc::uid_t::max_value());
assert_ne!(resuids.real.as_raw(), libc::uid_t::MAX);
assert_ne!(resuids.effective.as_raw(), libc::uid_t::MAX);
assert_ne!(resuids.saved.as_raw(), libc::uid_t::MAX);
}

#[cfg(any(
Expand All @@ -709,9 +709,9 @@ fn test_getresuid() {
#[test]
fn test_getresgid() {
let resgids = getresgid().unwrap();
assert!(resgids.real.as_raw() != libc::gid_t::max_value());
assert!(resgids.effective.as_raw() != libc::gid_t::max_value());
assert!(resgids.saved.as_raw() != libc::gid_t::max_value());
assert_ne!(resgids.real.as_raw(), libc::gid_t::MAX);
assert_ne!(resgids.effective.as_raw(), libc::gid_t::MAX);
assert_ne!(resgids.saved.as_raw(), libc::gid_t::MAX);
}

// Test that we can create a pair of pipes. No need to verify that they pass
Expand Down Expand Up @@ -1335,7 +1335,7 @@ fn test_faccessat_not_existing() {
Some(dirfd),
not_exist_file,
AccessFlags::F_OK,
AtFlags::empty()
AtFlags::empty(),
)
.err()
.unwrap(),
Expand All @@ -1354,7 +1354,7 @@ fn test_faccessat_none_file_exists() {
None,
&path,
AccessFlags::R_OK | AccessFlags::W_OK,
AtFlags::empty()
AtFlags::empty(),
)
.is_ok());
}
Expand All @@ -1372,7 +1372,7 @@ fn test_faccessat_file_exists() {
Some(dirfd),
&path,
AccessFlags::R_OK | AccessFlags::W_OK,
AtFlags::empty()
AtFlags::empty(),
)
.is_ok());
}