Skip to content

Commit d458ecd

Browse files
committed
remove deprecated items
1 parent a10078f commit d458ecd

File tree

14 files changed

+248
-248
lines changed

14 files changed

+248
-248
lines changed

src/sched.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ mod sched_affinity {
233233
/// use nix::unistd::Pid;
234234
///
235235
/// let mut cpu_set = CpuSet::new();
236-
/// cpu_set.set(0);
237-
/// sched_setaffinity(Pid::from_raw(0), &cpu_set);
236+
/// cpu_set.set(0).unwrap();
237+
/// sched_setaffinity(Pid::from_raw(0), &cpu_set).unwrap();
238238
/// ```
239239
pub fn sched_setaffinity(pid: Pid, cpuset: &CpuSet) -> Result<()> {
240240
let res = unsafe {

src/sys/personality.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub fn get() -> Result<Persona> {
8686
/// # use nix::sys::personality::{self, Persona};
8787
/// let mut pers = personality::get().unwrap();
8888
/// assert!(!pers.contains(Persona::ADDR_NO_RANDOMIZE));
89-
/// personality::set(pers | Persona::ADDR_NO_RANDOMIZE);
89+
/// personality::set(pers | Persona::ADDR_NO_RANDOMIZE).unwrap().unwrap();
9090
/// ```
9191
pub fn set(persona: Persona) -> Result<Persona> {
9292
let res = unsafe {

src/sys/quota.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
//!
77
//! ```rust,no_run
88
//! # use nix::sys::quota::{Dqblk, quotactl_on, quotactl_set, QuotaFmt, QuotaType, QuotaValidFlags};
9-
//! quotactl_on(QuotaType::USRQUOTA, "/dev/sda1", QuotaFmt::QFMT_VFS_V1, "aquota.user");
9+
//! quotactl_on(QuotaType::USRQUOTA, "/dev/sda1", QuotaFmt::QFMT_VFS_V1, "aquota.user").unwrap();
1010
//! let mut dqblk: Dqblk = Default::default();
1111
//! dqblk.set_blocks_hard_limit(10000);
1212
//! dqblk.set_blocks_soft_limit(8000);
13-
//! quotactl_set(QuotaType::USRQUOTA, "/dev/sda1", 50, &dqblk, QuotaValidFlags::QIF_BLIMITS);
13+
//! quotactl_set(QuotaType::USRQUOTA, "/dev/sda1", 50, &dqblk, QuotaValidFlags::QIF_BLIMITS).unwrap();
1414
//! ```
1515
use std::default::Default;
1616
use std::{mem, ptr};

src/sys/socket/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ pub enum ControlMessageOwned {
677677
/// None).unwrap();
678678
/// setsockopt(in_socket, sockopt::ReceiveTimestamp, &true).unwrap();
679679
/// let localhost = SockaddrIn::from_str("127.0.0.1:0").unwrap();
680-
/// bind(in_socket, &localhost);
680+
/// bind(in_socket, &localhost).unwrap();
681681
/// let address: SockaddrIn = getsockname(in_socket).unwrap();
682682
/// // Get initial time
683683
/// let time0 = SystemTime::now();

src/sys/socket/sockopt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ mod test {
982982
let a_cred = getsockopt(a, super::PeerCredentials).unwrap();
983983
let b_cred = getsockopt(b, super::PeerCredentials).unwrap();
984984
assert_eq!(a_cred, b_cred);
985-
assert!(a_cred.pid() != 0);
985+
assert_ne!(a_cred.pid(), 0);
986986
}
987987

988988
#[test]

src/sys/termios.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@
6464
//! # use nix::sys::termios::{BaudRate, cfsetispeed, cfsetospeed, cfsetspeed, Termios};
6565
//! # fn main() {
6666
//! # let mut t: Termios = unsafe { std::mem::zeroed() };
67-
//! cfsetispeed(&mut t, BaudRate::B9600);
68-
//! cfsetospeed(&mut t, BaudRate::B9600);
69-
//! cfsetspeed(&mut t, BaudRate::B9600);
67+
//! cfsetispeed(&mut t, BaudRate::B9600).unwrap();
68+
//! cfsetospeed(&mut t, BaudRate::B9600).unwrap();
69+
//! cfsetspeed(&mut t, BaudRate::B9600).unwrap();
7070
//! # }
7171
//! ```
7272
//!
@@ -76,10 +76,10 @@
7676
//! # use nix::sys::termios::{BaudRate, cfgetispeed, cfgetospeed, cfsetispeed, cfsetspeed, Termios};
7777
//! # fn main() {
7878
//! # let mut t: Termios = unsafe { std::mem::zeroed() };
79-
//! # cfsetspeed(&mut t, BaudRate::B9600);
79+
//! # cfsetspeed(&mut t, BaudRate::B9600).unwrap();
8080
//! let speed = cfgetispeed(&t);
8181
//! assert_eq!(speed, cfgetospeed(&t));
82-
//! cfsetispeed(&mut t, speed);
82+
//! cfsetispeed(&mut t, speed).unwrap();
8383
//! # }
8484
//! ```
8585
//!

src/sys/time.rs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ use std::time::Duration;
77
use std::{cmp, fmt, ops};
88

99
#[cfg(any(
10-
all(feature = "time", any(target_os = "android", target_os = "linux")),
11-
all(
12-
any(
13-
target_os = "freebsd",
14-
target_os = "illumos",
15-
target_os = "linux",
16-
target_os = "netbsd"
17-
),
18-
feature = "time",
19-
feature = "signal"
20-
)
10+
all(feature = "time", any(target_os = "android", target_os = "linux")),
11+
all(
12+
any(
13+
target_os = "freebsd",
14+
target_os = "illumos",
15+
target_os = "linux",
16+
target_os = "netbsd"
17+
),
18+
feature = "time",
19+
feature = "signal"
20+
)
2121
))]
2222
pub(crate) mod timer {
2323
use crate::sys::time::TimeSpec;
@@ -98,10 +98,10 @@ pub(crate) mod timer {
9898
}
9999
}
100100
#[cfg(any(
101-
target_os = "freebsd",
102-
target_os = "netbsd",
103-
target_os = "dragonfly",
104-
target_os = "illumos"
101+
target_os = "freebsd",
102+
target_os = "netbsd",
103+
target_os = "dragonfly",
104+
target_os = "illumos"
105105
))]
106106
bitflags! {
107107
/// Flags that are used for arming the timer.
@@ -114,17 +114,17 @@ pub(crate) mod timer {
114114
fn from(timerspec: TimerSpec) -> Expiration {
115115
match timerspec {
116116
TimerSpec(libc::itimerspec {
117-
it_interval:
118-
libc::timespec {
119-
tv_sec: 0,
120-
tv_nsec: 0,
121-
},
122-
it_value: ts,
123-
}) => Expiration::OneShot(ts.into()),
117+
it_interval:
118+
libc::timespec {
119+
tv_sec: 0,
120+
tv_nsec: 0,
121+
},
122+
it_value: ts,
123+
}) => Expiration::OneShot(ts.into()),
124124
TimerSpec(libc::itimerspec {
125-
it_interval: int_ts,
126-
it_value: val_ts,
127-
}) => {
125+
it_interval: int_ts,
126+
it_value: val_ts,
127+
}) => {
128128
if (int_ts.tv_sec == val_ts.tv_sec)
129129
&& (int_ts.tv_nsec == val_ts.tv_nsec)
130130
{
@@ -193,7 +193,7 @@ const SECS_PER_MINUTE: i64 = 60;
193193
const SECS_PER_HOUR: i64 = 3600;
194194

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

198198
#[cfg(target_pointer_width = "32")]
199199
const TS_MAX_SECONDS: i64 = ::std::isize::MAX as i64;
@@ -453,7 +453,7 @@ pub struct TimeVal(timeval);
453453
const MICROS_PER_SEC: i64 = 1_000_000;
454454

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

458458
#[cfg(target_pointer_width = "32")]
459459
const TV_MAX_SECONDS: i64 = ::std::isize::MAX as i64;
@@ -713,7 +713,7 @@ mod test {
713713

714714
#[test]
715715
pub fn test_timespec() {
716-
assert!(TimeSpec::seconds(1) != TimeSpec::zero());
716+
assert_ne!(TimeSpec::seconds(1), TimeSpec::zero());
717717
assert_eq!(
718718
TimeSpec::seconds(1) + TimeSpec::seconds(2),
719719
TimeSpec::seconds(3)
@@ -743,7 +743,7 @@ mod test {
743743

744744
#[test]
745745
pub fn test_timespec_ord() {
746-
assert!(TimeSpec::seconds(1) == TimeSpec::nanoseconds(1_000_000_000));
746+
assert_eq!(TimeSpec::seconds(1), TimeSpec::nanoseconds(1_000_000_000));
747747
assert!(TimeSpec::seconds(1) < TimeSpec::nanoseconds(1_000_000_001));
748748
assert!(TimeSpec::seconds(1) > TimeSpec::nanoseconds(999_999_999));
749749
assert!(TimeSpec::seconds(-1) < TimeSpec::nanoseconds(-999_999_999));
@@ -765,7 +765,7 @@ mod test {
765765

766766
#[test]
767767
pub fn test_timeval() {
768-
assert!(TimeVal::seconds(1) != TimeVal::zero());
768+
assert_ne!(TimeVal::seconds(1), TimeVal::zero());
769769
assert_eq!(
770770
TimeVal::seconds(1) + TimeVal::seconds(2),
771771
TimeVal::seconds(3)
@@ -778,7 +778,7 @@ mod test {
778778

779779
#[test]
780780
pub fn test_timeval_ord() {
781-
assert!(TimeVal::seconds(1) == TimeVal::microseconds(1_000_000));
781+
assert_eq!(TimeVal::seconds(1), TimeVal::microseconds(1_000_000));
782782
assert!(TimeVal::seconds(1) < TimeVal::microseconds(1_000_001));
783783
assert!(TimeVal::seconds(1) > TimeVal::microseconds(999_999));
784784
assert!(TimeVal::seconds(-1) < TimeVal::microseconds(-999_999));

src/unistd.rs

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ use crate::fcntl::{at_rawfd, AtFlags};
77
#[cfg(feature = "fs")]
88
use crate::fcntl::{fcntl, FcntlArg::F_SETFD, FdFlag, OFlag};
99
#[cfg(all(
10-
feature = "fs",
11-
any(
12-
target_os = "openbsd",
13-
target_os = "netbsd",
14-
target_os = "freebsd",
15-
target_os = "dragonfly",
16-
target_os = "macos",
17-
target_os = "ios"
18-
)
10+
feature = "fs",
11+
any(
12+
target_os = "openbsd",
13+
target_os = "netbsd",
14+
target_os = "freebsd",
15+
target_os = "dragonfly",
16+
target_os = "macos",
17+
target_os = "ios"
18+
)
1919
))]
2020
use crate::sys::stat::FileFlag;
2121
#[cfg(feature = "fs")]
@@ -45,20 +45,20 @@ feature! {
4545
}
4646

4747
#[cfg(any(
48-
target_os = "android",
49-
target_os = "dragonfly",
50-
target_os = "freebsd",
51-
target_os = "linux",
52-
target_os = "openbsd"
48+
target_os = "android",
49+
target_os = "dragonfly",
50+
target_os = "freebsd",
51+
target_os = "linux",
52+
target_os = "openbsd"
5353
))]
5454
pub use self::setres::*;
5555

5656
#[cfg(any(
57-
target_os = "android",
58-
target_os = "dragonfly",
59-
target_os = "freebsd",
60-
target_os = "linux",
61-
target_os = "openbsd"
57+
target_os = "android",
58+
target_os = "dragonfly",
59+
target_os = "freebsd",
60+
target_os = "linux",
61+
target_os = "openbsd"
6262
))]
6363
pub use self::getres::*;
6464

@@ -1572,7 +1572,7 @@ pub fn getgroups() -> Result<Vec<Gid>> {
15721572
/// # use std::error::Error;
15731573
/// # use nix::unistd::*;
15741574
/// #
1575-
/// # fn try_main() -> Result<(), Box<Error>> {
1575+
/// # fn try_main() -> Result<(), Box<dyn Error>> {
15761576
/// let uid = Uid::from_raw(33);
15771577
/// let gid = Gid::from_raw(34);
15781578
/// setgroups(&[gid])?;
@@ -1698,7 +1698,7 @@ pub fn getgrouplist(user: &CStr, group: Gid) -> Result<Vec<Gid>> {
16981698
/// # use std::ffi::CString;
16991699
/// # use nix::unistd::*;
17001700
/// #
1701-
/// # fn try_main() -> Result<(), Box<Error>> {
1701+
/// # fn try_main() -> Result<(), Box<dyn Error>> {
17021702
/// let user = CString::new("www-data").unwrap();
17031703
/// let uid = Uid::from_raw(33);
17041704
/// let gid = Gid::from_raw(33);
@@ -2752,11 +2752,11 @@ mod pivot_root {
27522752
}
27532753

27542754
#[cfg(any(
2755-
target_os = "android",
2756-
target_os = "dragonfly",
2757-
target_os = "freebsd",
2758-
target_os = "linux",
2759-
target_os = "openbsd"
2755+
target_os = "android",
2756+
target_os = "dragonfly",
2757+
target_os = "freebsd",
2758+
target_os = "linux",
2759+
target_os = "openbsd"
27602760
))]
27612761
mod setres {
27622762
feature! {
@@ -2801,11 +2801,11 @@ mod setres {
28012801
}
28022802

28032803
#[cfg(any(
2804-
target_os = "android",
2805-
target_os = "dragonfly",
2806-
target_os = "freebsd",
2807-
target_os = "linux",
2808-
target_os = "openbsd"
2804+
target_os = "android",
2805+
target_os = "dragonfly",
2806+
target_os = "freebsd",
2807+
target_os = "linux",
2808+
target_os = "openbsd"
28092809
))]
28102810
mod getres {
28112811
feature! {
@@ -3121,7 +3121,7 @@ impl User {
31213121
/// use nix::unistd::{Uid, User};
31223122
/// // Returns an Result<Option<User>>, thus the double unwrap.
31233123
/// let res = User::from_uid(Uid::from_raw(0)).unwrap().unwrap();
3124-
/// assert!(res.name == "root");
3124+
/// assert_eq!(res.name, "root");
31253125
/// ```
31263126
pub fn from_uid(uid: Uid) -> Result<Option<Self>> {
31273127
User::from_anything(|pwd, cbuf, cap, res| {
@@ -3140,7 +3140,7 @@ impl User {
31403140
/// use nix::unistd::User;
31413141
/// // Returns an Result<Option<User>>, thus the double unwrap.
31423142
/// let res = User::from_name("root").unwrap().unwrap();
3143-
/// assert!(res.name == "root");
3143+
/// assert_eq!(res.name, "root");
31443144
/// ```
31453145
pub fn from_name(name: &str) -> Result<Option<Self>> {
31463146
let name = CString::new(name).unwrap();

test/sys/test_pthread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fn test_pthread_self() {
1111
#[test]
1212
fn test_pthread_self() {
1313
let tid = pthread_self();
14-
assert!(tid != 0);
14+
assert_ne!(tid, 0);
1515
}
1616

1717
#[test]

0 commit comments

Comments
 (0)