diff options
Diffstat (limited to 'src/sys')
-rw-r--r-- | src/sys/personality.rs | 2 | ||||
-rw-r--r-- | src/sys/quota.rs | 4 | ||||
-rw-r--r-- | src/sys/socket/mod.rs | 2 | ||||
-rw-r--r-- | src/sys/socket/sockopt.rs | 2 | ||||
-rw-r--r-- | src/sys/termios.rs | 10 | ||||
-rw-r--r-- | src/sys/time.rs | 62 |
6 files changed, 41 insertions, 41 deletions
diff --git a/src/sys/personality.rs b/src/sys/personality.rs index 2af66878..15b59017 100644 --- a/src/sys/personality.rs +++ b/src/sys/personality.rs @@ -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().unwrap(); /// ``` pub fn set(persona: Persona) -> Result<Persona> { let res = unsafe { diff --git a/src/sys/quota.rs b/src/sys/quota.rs index 6e34e38d..f3b4c02d 100644 --- a/src/sys/quota.rs +++ b/src/sys/quota.rs @@ -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}; diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index 2dfa8ec6..7e6d6094 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -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(); diff --git a/src/sys/socket/sockopt.rs b/src/sys/socket/sockopt.rs index fff496db..1cbb223e 100644 --- a/src/sys/socket/sockopt.rs +++ b/src/sys/socket/sockopt.rs @@ -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] diff --git a/src/sys/termios.rs b/src/sys/termios.rs index feb52c0a..c5b27d28 100644 --- a/src/sys/termios.rs +++ b/src/sys/termios.rs @@ -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(); //! # } //! ``` //! @@ -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(); //! # } //! ``` //! diff --git a/src/sys/time.rs b/src/sys/time.rs index b7ab3986..36279978 100644 --- a/src/sys/time.rs +++ b/src/sys/time.rs @@ -7,17 +7,17 @@ use std::time::Duration; use std::{cmp, fmt, ops}; #[cfg(any( - all(feature = "time", any(target_os = "android", target_os = "linux")), - all( - any( - target_os = "freebsd", - target_os = "illumos", - target_os = "linux", - target_os = "netbsd" - ), - feature = "time", - feature = "signal" - ) +all(feature = "time", any(target_os = "android", target_os = "linux")), +all( +any( +target_os = "freebsd", +target_os = "illumos", +target_os = "linux", +target_os = "netbsd" +), +feature = "time", +feature = "signal" +) ))] pub(crate) mod timer { use crate::sys::time::TimeSpec; @@ -98,10 +98,10 @@ pub(crate) mod timer { } } #[cfg(any( - target_os = "freebsd", - target_os = "netbsd", - target_os = "dragonfly", - target_os = "illumos" + target_os = "freebsd", + target_os = "netbsd", + target_os = "dragonfly", + target_os = "illumos" ))] bitflags! { /// Flags that are used for arming the timer. @@ -114,17 +114,17 @@ pub(crate) mod timer { fn from(timerspec: TimerSpec) -> Expiration { match timerspec { TimerSpec(libc::itimerspec { - it_interval: - libc::timespec { - tv_sec: 0, - tv_nsec: 0, - }, - it_value: ts, - }) => Expiration::OneShot(ts.into()), + it_interval: + libc::timespec { + tv_sec: 0, + tv_nsec: 0, + }, + it_value: ts, + }) => Expiration::OneShot(ts.into()), TimerSpec(libc::itimerspec { - it_interval: int_ts, - it_value: val_ts, - }) => { + it_interval: int_ts, + it_value: val_ts, + }) => { if (int_ts.tv_sec == val_ts.tv_sec) && (int_ts.tv_nsec == val_ts.tv_nsec) { @@ -193,7 +193,7 @@ 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; @@ -453,7 +453,7 @@ 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; @@ -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) @@ -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)); @@ -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) @@ -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)); |