summaryrefslogtreecommitdiff
path: root/src/sys
diff options
context:
space:
mode:
authorAlan Somers <asomers@gmail.com>2021-09-18 21:07:00 -0600
committerAlan Somers <asomers@gmail.com>2021-09-19 07:58:15 -0600
commita09b1c8ac643d448db479a108ac6726307075453 (patch)
tree654a84d639d1feca971396f958f7589fc1fb81bf /src/sys
parentf0d6d0406d8e763619aecac062d1d2b56ca6e7b2 (diff)
downloadnix-a09b1c8ac643d448db479a108ac6726307075453.zip
Clippy cleanup
And this time, start running Clippy in CI
Diffstat (limited to 'src/sys')
-rw-r--r--src/sys/aio.rs44
-rw-r--r--src/sys/epoll.rs4
-rw-r--r--src/sys/eventfd.rs1
-rw-r--r--src/sys/memfd.rs1
-rw-r--r--src/sys/mman.rs6
-rw-r--r--src/sys/personality.rs4
-rw-r--r--src/sys/ptrace/linux.rs17
-rw-r--r--src/sys/reboot.rs5
-rw-r--r--src/sys/select.rs2
-rw-r--r--src/sys/signal.rs6
-rw-r--r--src/sys/signalfd.rs5
-rw-r--r--src/sys/socket/addr.rs16
-rw-r--r--src/sys/socket/mod.rs11
-rw-r--r--src/sys/statvfs.rs2
-rw-r--r--src/sys/timerfd.rs11
15 files changed, 55 insertions, 80 deletions
diff --git a/src/sys/aio.rs b/src/sys/aio.rs
index fcee28c5..e64a2a82 100644
--- a/src/sys/aio.rs
+++ b/src/sys/aio.rs
@@ -21,7 +21,7 @@
//! [`aio_cancel_all`](fn.aio_cancel_all.html), though the operating system may
//! not support this for all filesystems and devices.
-use crate::{Error, Result};
+use crate::Result;
use crate::errno::Errno;
use std::os::unix::io::RawFd;
use libc::{c_void, off_t, size_t};
@@ -148,15 +148,13 @@ impl<'a> AioCb<'a> {
/// # use std::{thread, time};
/// # use std::os::unix::io::AsRawFd;
/// # use tempfile::tempfile;
- /// # fn main() {
/// let f = tempfile().unwrap();
/// let mut aiocb = AioCb::from_fd( f.as_raw_fd(), 0, SigevNone);
/// aiocb.fsync(AioFsyncMode::O_SYNC).expect("aio_fsync failed early");
- /// while (aiocb.error() == Err(Error::from(Errno::EINPROGRESS))) {
+ /// while (aiocb.error() == Err(Errno::EINPROGRESS)) {
/// thread::sleep(time::Duration::from_millis(10));
/// }
/// aiocb.aio_return().expect("aio_fsync failed late");
- /// # }
/// ```
pub fn from_fd(fd: RawFd, prio: libc::c_int,
sigev_notify: SigevNotify) -> Pin<Box<AioCb<'a>>> {
@@ -229,7 +227,6 @@ impl<'a> AioCb<'a> {
/// # use std::io::Write;
/// # use std::os::unix::io::AsRawFd;
/// # use tempfile::tempfile;
- /// # fn main() {
/// const INITIAL: &[u8] = b"abcdef123456";
/// const LEN: usize = 4;
/// let mut rbuf = vec![0; LEN];
@@ -243,13 +240,12 @@ impl<'a> AioCb<'a> {
/// SigevNotify::SigevNone,
/// LioOpcode::LIO_NOP);
/// aiocb.read().unwrap();
- /// while (aiocb.error() == Err(Error::from(Errno::EINPROGRESS))) {
+ /// while (aiocb.error() == Err(Errno::EINPROGRESS)) {
/// thread::sleep(time::Duration::from_millis(10));
/// }
/// assert_eq!(aiocb.aio_return().unwrap() as usize, LEN);
/// }
/// assert_eq!(rbuf, b"cdef");
- /// # }
/// ```
pub fn from_mut_slice(fd: RawFd, offs: off_t, buf: &'a mut [u8],
prio: libc::c_int, sigev_notify: SigevNotify,
@@ -404,7 +400,6 @@ impl<'a> AioCb<'a> {
/// # use std::{thread, time};
/// # use std::os::unix::io::AsRawFd;
/// # use tempfile::tempfile;
- /// # fn main() {
/// const WBUF: &[u8] = b"abcdef123456";
/// let mut f = tempfile().unwrap();
/// let mut aiocb = AioCb::from_slice( f.as_raw_fd(),
@@ -414,11 +409,10 @@ impl<'a> AioCb<'a> {
/// SigevNotify::SigevNone,
/// LioOpcode::LIO_NOP);
/// aiocb.write().unwrap();
- /// while (aiocb.error() == Err(Error::from(Errno::EINPROGRESS))) {
+ /// while (aiocb.error() == Err(Errno::EINPROGRESS)) {
/// thread::sleep(time::Duration::from_millis(10));
/// }
/// assert_eq!(aiocb.aio_return().unwrap() as usize, WBUF.len());
- /// # }
/// ```
// Note: another solution to the problem of writing const buffers would be
// to genericize AioCb for both &mut [u8] and &[u8] buffers. AioCb::read
@@ -480,7 +474,6 @@ impl<'a> AioCb<'a> {
/// # use std::io::Write;
/// # use std::os::unix::io::AsRawFd;
/// # use tempfile::tempfile;
- /// # fn main() {
/// let wbuf = b"CDEF";
/// let mut f = tempfile().unwrap();
/// let mut aiocb = AioCb::from_slice( f.as_raw_fd(),
@@ -492,13 +485,12 @@ impl<'a> AioCb<'a> {
/// aiocb.write().unwrap();
/// let cs = aiocb.cancel().unwrap();
/// if cs == AioCancelStat::AioNotCanceled {
- /// while (aiocb.error() == Err(Error::from(Errno::EINPROGRESS))) {
+ /// while (aiocb.error() == Err(Errno::EINPROGRESS)) {
/// thread::sleep(time::Duration::from_millis(10));
/// }
/// }
/// // Must call `aio_return`, but ignore the result
/// let _ = aiocb.aio_return();
- /// # }
/// ```
///
/// # References
@@ -513,7 +505,7 @@ impl<'a> AioCb<'a> {
libc::AIO_CANCELED => Ok(AioCancelStat::AioCanceled),
libc::AIO_NOTCANCELED => Ok(AioCancelStat::AioNotCanceled),
libc::AIO_ALLDONE => Ok(AioCancelStat::AioAllDone),
- -1 => Err(Error::from(Errno::last())),
+ -1 => Err(Errno::last()),
_ => panic!("unknown aio_cancel return value")
}
}
@@ -524,8 +516,8 @@ impl<'a> AioCb<'a> {
};
match r {
0 => Ok(()),
- num if num > 0 => Err(Error::from(Errno::from_i32(num))),
- -1 => Err(Error::from(Errno::last())),
+ num if num > 0 => Err(Errno::from_i32(num)),
+ -1 => Err(Errno::last()),
num => panic!("unknown aio_error return value {:?}", num)
}
}
@@ -548,7 +540,6 @@ impl<'a> AioCb<'a> {
/// # use std::{thread, time};
/// # use std::os::unix::io::AsRawFd;
/// # use tempfile::tempfile;
- /// # fn main() {
/// const WBUF: &[u8] = b"abcdef123456";
/// let mut f = tempfile().unwrap();
/// let mut aiocb = AioCb::from_slice( f.as_raw_fd(),
@@ -558,11 +549,10 @@ impl<'a> AioCb<'a> {
/// SigevNotify::SigevNone,
/// LioOpcode::LIO_NOP);
/// aiocb.write().unwrap();
- /// while (aiocb.error() == Err(Error::from(Errno::EINPROGRESS))) {
+ /// while (aiocb.error() == Err(Errno::EINPROGRESS)) {
/// thread::sleep(time::Duration::from_millis(10));
/// }
/// assert_eq!(aiocb.aio_return().unwrap() as usize, WBUF.len());
- /// # }
/// ```
///
/// # References
@@ -711,7 +701,6 @@ impl<'a> AioCb<'a> {
/// # use std::io::Write;
/// # use std::os::unix::io::AsRawFd;
/// # use tempfile::tempfile;
-/// # fn main() {
/// let wbuf = b"CDEF";
/// let mut f = tempfile().unwrap();
/// let mut aiocb = AioCb::from_slice( f.as_raw_fd(),
@@ -723,13 +712,12 @@ impl<'a> AioCb<'a> {
/// aiocb.write().unwrap();
/// let cs = aio_cancel_all(f.as_raw_fd()).unwrap();
/// if cs == AioCancelStat::AioNotCanceled {
-/// while (aiocb.error() == Err(Error::from(Errno::EINPROGRESS))) {
+/// while (aiocb.error() == Err(Errno::EINPROGRESS)) {
/// thread::sleep(time::Duration::from_millis(10));
/// }
/// }
/// // Must call `aio_return`, but ignore the result
/// let _ = aiocb.aio_return();
-/// # }
/// ```
///
/// # References
@@ -740,7 +728,7 @@ pub fn aio_cancel_all(fd: RawFd) -> Result<AioCancelStat> {
libc::AIO_CANCELED => Ok(AioCancelStat::AioCanceled),
libc::AIO_NOTCANCELED => Ok(AioCancelStat::AioNotCanceled),
libc::AIO_ALLDONE => Ok(AioCancelStat::AioAllDone),
- -1 => Err(Error::from(Errno::last())),
+ -1 => Err(Errno::last()),
_ => panic!("unknown aio_cancel return value")
}
}
@@ -759,7 +747,6 @@ pub fn aio_cancel_all(fd: RawFd) -> Result<AioCancelStat> {
/// # use nix::sys::signal::SigevNotify;
/// # use std::os::unix::io::AsRawFd;
/// # use tempfile::tempfile;
-/// # fn main() {
/// const WBUF: &[u8] = b"abcdef123456";
/// let mut f = tempfile().unwrap();
/// let mut aiocb = AioCb::from_slice( f.as_raw_fd(),
@@ -771,7 +758,6 @@ pub fn aio_cancel_all(fd: RawFd) -> Result<AioCancelStat> {
/// aiocb.write().unwrap();
/// aio_suspend(&[aiocb.as_ref()], None).expect("aio_suspend failed");
/// assert_eq!(aiocb.aio_return().unwrap() as usize, WBUF.len());
-/// # }
/// ```
/// # References
///
@@ -876,7 +862,6 @@ impl<'a> LioCb<'a> {
/// # use nix::sys::signal::SigevNotify;
/// # use std::os::unix::io::AsRawFd;
/// # use tempfile::tempfile;
- /// # fn main() {
/// const WBUF: &[u8] = b"abcdef123456";
/// let mut f = tempfile().unwrap();
/// let mut liocb = LioCbBuilder::with_capacity(1)
@@ -891,7 +876,6 @@ impl<'a> LioCb<'a> {
/// liocb.listio(LioMode::LIO_WAIT,
/// SigevNotify::SigevNone).unwrap();
/// assert_eq!(liocb.aio_return(0).unwrap() as usize, WBUF.len());
- /// # }
/// ```
///
/// # References
@@ -936,7 +920,6 @@ impl<'a> LioCb<'a> {
/// # use std::os::unix::io::AsRawFd;
/// # use std::{thread, time};
/// # use tempfile::tempfile;
- /// # fn main() {
/// const WBUF: &[u8] = b"abcdef123456";
/// let mut f = tempfile().unwrap();
/// let mut liocb = LioCbBuilder::with_capacity(1)
@@ -949,13 +932,12 @@ impl<'a> LioCb<'a> {
/// LioOpcode::LIO_WRITE
/// ).finish();
/// let mut err = liocb.listio(LioMode::LIO_WAIT, SigevNotify::SigevNone);
- /// while err == Err(Error::from(Errno::EIO)) ||
- /// err == Err(Error::from(Errno::EAGAIN)) {
+ /// while err == Err(Errno::EIO) ||
+ /// err == Err(Errno::EAGAIN) {
/// thread::sleep(time::Duration::from_millis(10));
/// err = liocb.listio_resubmit(LioMode::LIO_WAIT, SigevNotify::SigevNone);
/// }
/// assert_eq!(liocb.aio_return(0).unwrap() as usize, WBUF.len());
- /// # }
/// ```
///
/// # References
diff --git a/src/sys/epoll.rs b/src/sys/epoll.rs
index 9f68d5ce..6bc2a253 100644
--- a/src/sys/epoll.rs
+++ b/src/sys/epoll.rs
@@ -1,4 +1,4 @@
-use crate::{Error, Result};
+use crate::Result;
use crate::errno::Errno;
use libc::{self, c_int};
use std::os::unix::io::RawFd;
@@ -86,7 +86,7 @@ pub fn epoll_ctl<'a, T>(epfd: RawFd, op: EpollOp, fd: RawFd, event: T) -> Result
{
let mut event: Option<&mut EpollEvent> = event.into();
if event.is_none() && op != EpollOp::EpollCtlDel {
- Err(Error::from(Errno::EINVAL))
+ Err(Errno::EINVAL)
} else {
let res = unsafe {
if let Some(ref mut event) = event {
diff --git a/src/sys/eventfd.rs b/src/sys/eventfd.rs
index baaaa89d..c54f952f 100644
--- a/src/sys/eventfd.rs
+++ b/src/sys/eventfd.rs
@@ -1,4 +1,3 @@
-use libc;
use std::os::unix::io::RawFd;
use crate::Result;
use crate::errno::Errno;
diff --git a/src/sys/memfd.rs b/src/sys/memfd.rs
index 51b7e6b1..0236eef6 100644
--- a/src/sys/memfd.rs
+++ b/src/sys/memfd.rs
@@ -1,4 +1,3 @@
-use libc;
use std::os::unix::io::RawFd;
use crate::Result;
use crate::errno::Errno;
diff --git a/src/sys/mman.rs b/src/sys/mman.rs
index e3c36208..0ea7edaf 100644
--- a/src/sys/mman.rs
+++ b/src/sys/mman.rs
@@ -1,4 +1,4 @@
-use crate::{Error, Result};
+use crate::Result;
#[cfg(not(target_os = "android"))]
use crate::NixPath;
use crate::errno::Errno;
@@ -333,7 +333,7 @@ pub unsafe fn mmap(addr: *mut c_void, length: size_t, prot: ProtFlags, flags: Ma
let ret = libc::mmap(addr, length, prot.bits(), flags.bits(), fd, offset);
if ret == libc::MAP_FAILED {
- Err(Error::from(Errno::last()))
+ Err(Errno::last())
} else {
Ok(ret)
}
@@ -366,7 +366,7 @@ pub unsafe fn mremap(
);
if ret == libc::MAP_FAILED {
- Err(Error::from(Errno::last()))
+ Err(Errno::last())
} else {
Ok(ret)
}
diff --git a/src/sys/personality.rs b/src/sys/personality.rs
index 6548b654..b15956c4 100644
--- a/src/sys/personality.rs
+++ b/src/sys/personality.rs
@@ -39,7 +39,7 @@ pub fn get() -> Result<Persona> {
libc::personality(0xFFFFFFFF)
};
- Errno::result(res).map(|r| Persona::from_bits_truncate(r))
+ Errno::result(res).map(Persona::from_bits_truncate)
}
/// Set the current process personality.
@@ -66,5 +66,5 @@ pub fn set(persona: Persona) -> Result<Persona> {
libc::personality(persona.bits() as c_ulong)
};
- Errno::result(res).map(|r| Persona::from_bits_truncate(r))
+ Errno::result(res).map(Persona::from_bits_truncate)
}
diff --git a/src/sys/ptrace/linux.rs b/src/sys/ptrace/linux.rs
index 1bfde0d2..37236790 100644
--- a/src/sys/ptrace/linux.rs
+++ b/src/sys/ptrace/linux.rs
@@ -415,16 +415,15 @@ pub fn kill(pid: Pid) -> Result<()> {
/// use nix::unistd::Pid;
/// use nix::sys::signal::Signal;
/// use nix::sys::wait::*;
-/// fn main() {
-/// // If a process changes state to the stopped state because of a SIGUSR1
-/// // signal, this will step the process forward and forward the user
-/// // signal to the stopped process
-/// match waitpid(Pid::from_raw(-1), None) {
-/// Ok(WaitStatus::Stopped(pid, Signal::SIGUSR1)) => {
-/// let _ = step(pid, Signal::SIGUSR1);
-/// }
-/// _ => {},
+///
+/// // If a process changes state to the stopped state because of a SIGUSR1
+/// // signal, this will step the process forward and forward the user
+/// // signal to the stopped process
+/// match waitpid(Pid::from_raw(-1), None) {
+/// Ok(WaitStatus::Stopped(pid, Signal::SIGUSR1)) => {
+/// let _ = step(pid, Signal::SIGUSR1);
/// }
+/// _ => {},
/// }
/// ```
pub fn step<T: Into<Option<Signal>>>(pid: Pid, sig: T) -> Result<()> {
diff --git a/src/sys/reboot.rs b/src/sys/reboot.rs
index be5067a9..46ab68b6 100644
--- a/src/sys/reboot.rs
+++ b/src/sys/reboot.rs
@@ -1,8 +1,7 @@
//! Reboot/shutdown or enable/disable Ctrl-Alt-Delete.
-use crate::{Error, Result};
+use crate::Result;
use crate::errno::Errno;
-use libc;
use std::convert::Infallible;
use std::mem::drop;
@@ -27,7 +26,7 @@ pub fn reboot(how: RebootMode) -> Result<Infallible> {
unsafe {
libc::reboot(how as libc::c_int)
};
- Err(Error::from(Errno::last()))
+ Err(Errno::last())
}
/// Enable or disable the reboot keystroke (Ctrl-Alt-Delete).
diff --git a/src/sys/select.rs b/src/sys/select.rs
index 0a0e830d..5f3337f3 100644
--- a/src/sys/select.rs
+++ b/src/sys/select.rs
@@ -111,7 +111,7 @@ impl<'a> Iterator for Fds<'a> {
type Item = RawFd;
fn next(&mut self) -> Option<RawFd> {
- while let Some(i) = self.range.next() {
+ for i in &mut self.range {
if self.set.contains(i as RawFd) {
return Some(i as RawFd);
}
diff --git a/src/sys/signal.rs b/src/sys/signal.rs
index 1011930f..e8c79d33 100644
--- a/src/sys/signal.rs
+++ b/src/sys/signal.rs
@@ -156,7 +156,7 @@ impl FromStr for Signal {
target_os = "fuchsia", target_os = "linux",
target_os = "redox")))]
"SIGINFO" => Signal::SIGINFO,
- _ => return Err(Error::from(Errno::EINVAL)),
+ _ => return Err(Errno::EINVAL),
})
}
}
@@ -779,7 +779,7 @@ pub unsafe fn signal(signal: Signal, handler: SigHandler) -> Result<SigHandler>
SigHandler::SigIgn => libc::signal(signal, libc::SIG_IGN),
SigHandler::Handler(handler) => libc::signal(signal, handler as libc::sighandler_t),
#[cfg(not(target_os = "redox"))]
- SigHandler::SigAction(_) => return Err(Error::from(Errno::ENOTSUP)),
+ SigHandler::SigAction(_) => return Err(Errno::ENOTSUP),
};
Errno::result(res).map(|oldhandler| {
match oldhandler {
@@ -1091,7 +1091,7 @@ mod tests {
#[test]
fn test_from_str_invalid_value() {
- let errval = Err(Error::from(Errno::EINVAL));
+ let errval = Err(Errno::EINVAL);
assert_eq!("NOSIGNAL".parse::<Signal>(), errval);
assert_eq!("kill".parse::<Signal>(), errval);
assert_eq!("9".parse::<Signal>(), errval);
diff --git a/src/sys/signalfd.rs b/src/sys/signalfd.rs
index 2ede8b8f..bc4a4522 100644
--- a/src/sys/signalfd.rs
+++ b/src/sys/signalfd.rs
@@ -15,9 +15,8 @@
//!
//! Please note that signal discarding is not specific to `signalfd`, but also happens with regular
//! signal handlers.
-use libc;
use crate::unistd;
-use crate::{Error, Result};
+use crate::Result;
use crate::errno::Errno;
pub use crate::sys::signal::{self, SigSet};
pub use libc::signalfd_siginfo as siginfo;
@@ -117,7 +116,7 @@ impl SignalFd {
impl Drop for SignalFd {
fn drop(&mut self) {
let e = unistd::close(self.0);
- if !std::thread::panicking() && e == Err(Error::from(Errno::EBADF)) {
+ if !std::thread::panicking() && e == Err(Errno::EBADF) {
panic!("Closing an invalid file descriptor!");
};
}
diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs
index 38dd4190..832a153f 100644
--- a/src/sys/socket/addr.rs
+++ b/src/sys/socket/addr.rs
@@ -1,5 +1,5 @@
use super::sa_family_t;
-use crate::{Error, Result, NixPath};
+use crate::{Result, NixPath};
use crate::errno::Errno;
use memoffset::offset_of;
use std::{fmt, mem, net, ptr, slice};
@@ -270,6 +270,7 @@ pub enum InetAddr {
}
impl InetAddr {
+ #[allow(clippy::needless_update)] // It isn't needless on all OSes
pub fn from_std(std: &net::SocketAddr) -> InetAddr {
match *std {
net::SocketAddr::V4(ref addr) => {
@@ -293,6 +294,7 @@ impl InetAddr {
}
}
+ #[allow(clippy::needless_update)] // It isn't needless on all OSes
pub fn new(ip: IpAddr, port: u16) -> InetAddr {
match ip {
IpAddr::V4(ref ip) => {
@@ -565,7 +567,7 @@ impl UnixAddr {
let bytes = cstr.to_bytes();
if bytes.len() >= ret.sun_path.len() {
- return Err(Error::from(Errno::ENAMETOOLONG));
+ return Err(Errno::ENAMETOOLONG);
}
ptr::copy_nonoverlapping(bytes.as_ptr(),
@@ -592,7 +594,7 @@ impl UnixAddr {
};
if path.len() >= ret.sun_path.len() {
- return Err(Error::from(Errno::ENAMETOOLONG));
+ return Err(Errno::ENAMETOOLONG);
}
// Abstract addresses are represented by sun_path[0] ==
@@ -751,7 +753,7 @@ impl SockAddr {
#[cfg(any(target_os = "ios", target_os = "macos"))]
pub fn new_sys_control(sockfd: RawFd, name: &str, unit: u32) -> Result<SockAddr> {
- SysControlAddr::from_name(sockfd, name, unit).map(|a| SockAddr::SysControl(a))
+ SysControlAddr::from_name(sockfd, name, unit).map(SockAddr::SysControl)
}
#[cfg(any(target_os = "android", target_os = "linux"))]
@@ -1064,7 +1066,7 @@ pub mod sys_control {
use libc::{self, c_uchar};
use std::{fmt, mem};
use std::os::unix::io::RawFd;
- use crate::{Errno, Error, Result};
+ use crate::{Errno, Result};
// FIXME: Move type into `libc`
#[repr(C)]
@@ -1075,7 +1077,7 @@ pub mod sys_control {
pub ctl_name: [c_uchar; MAX_KCTL_NAME],
}
- const CTL_IOC_MAGIC: u8 = 'N' as u8;
+ const CTL_IOC_MAGIC: u8 = b'N';
const CTL_IOC_INFO: u8 = 3;
const MAX_KCTL_NAME: usize = 96;
@@ -1101,7 +1103,7 @@ pub mod sys_control {
pub fn from_name(sockfd: RawFd, name: &str, unit: u32) -> Result<SysControlAddr> {
if name.len() > MAX_KCTL_NAME {
- return Err(Error::from(Errno::ENAMETOOLONG));
+ return Err(Errno::ENAMETOOLONG);
}
let mut ctl_name = [0; MAX_KCTL_NAME];
diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs
index 96328842..97eea3dc 100644
--- a/src/sys/socket/mod.rs
+++ b/src/sys/socket/mod.rs
@@ -2,7 +2,7 @@
//!
//! [Further reading](https://man7.org/linux/man-pages/man7/socket.7.html)
use cfg_if::cfg_if;
-use crate::{Error, Result, errno::Errno};
+use crate::{Result, errno::Errno};
use libc::{self, c_void, c_int, iovec, socklen_t, size_t,
CMSG_FIRSTHDR, CMSG_NXTHDR, CMSG_DATA, CMSG_LEN};
use memoffset::offset_of;
@@ -311,9 +311,9 @@ cfg_if! {
}
}
- impl Into<libc::ucred> for UnixCredentials {
- fn into(self) -> libc::ucred {
- self.0
+ impl From<UnixCredentials> for libc::ucred {
+ fn from(uc: UnixCredentials) -> Self {
+ uc.0
}
}
} else if #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] {
@@ -1300,6 +1300,7 @@ pub struct RecvMmsgData<'a, I>
target_os = "freebsd",
target_os = "netbsd",
))]
+#[allow(clippy::needless_collect)] // Complicated false positive
pub fn recvmmsg<'a, I>(
fd: RawFd,
data: impl std::iter::IntoIterator<Item=&'a mut RecvMmsgData<'a, I>,
@@ -1813,7 +1814,7 @@ pub fn sockaddr_storage_to_addr(
assert!(len <= mem::size_of::<sockaddr_storage>());
if len < mem::size_of_val(&addr.ss_family) {
- return Err(Error::from(Errno::ENOTCONN));
+ return Err(Errno::ENOTCONN);
}
match c_int::from(addr.ss_family) {
diff --git a/src/sys/statvfs.rs b/src/sys/statvfs.rs
index 508fa8db..15e7a7d4 100644
--- a/src/sys/statvfs.rs
+++ b/src/sys/statvfs.rs
@@ -150,7 +150,7 @@ mod test {
#[test]
fn statvfs_call() {
- statvfs("/".as_bytes()).unwrap();
+ statvfs(&b"/"[..]).unwrap();
}
#[test]
diff --git a/src/sys/timerfd.rs b/src/sys/timerfd.rs
index 5d87b7c2..705a3c4d 100644
--- a/src/sys/timerfd.rs
+++ b/src/sys/timerfd.rs
@@ -257,14 +257,9 @@ impl TimerFd {
///
/// Note: If the alarm is unset, then you will wait forever.
pub fn wait(&self) -> Result<()> {
- loop {
- if let Err(e) = read(self.fd, &mut [0u8; 8]) {
- match e {
- Errno::EINTR => continue,
- _ => return Err(e),
- }
- } else {
- break;
+ while let Err(e) = read(self.fd, &mut [0u8; 8]) {
+ if e != Errno::EINTR {
+ return Err(e)
}
}