diff --git a/src/sys/epoll.rs b/src/sys/epoll.rs index 32b068e88b..88314ef926 100644 --- a/src/sys/epoll.rs +++ b/src/sys/epoll.rs @@ -1,6 +1,6 @@ use crate::errno::Errno; -use crate::Result; pub use crate::poll_timeout::PollTimeout as EpollTimeout; +use crate::Result; use libc::{self, c_int}; use std::mem; use std::os::unix::io::{AsFd, AsRawFd, FromRawFd, OwnedFd, RawFd}; diff --git a/src/sys/fanotify.rs b/src/sys/fanotify.rs index a089d78df8..e217406e02 100644 --- a/src/sys/fanotify.rs +++ b/src/sys/fanotify.rs @@ -10,12 +10,12 @@ //! For more documentation, please read //! [fanotify(7)](https://man7.org/linux/man-pages/man7/fanotify.7.html). -use crate::{NixPath, Result}; use crate::errno::Errno; -use crate::fcntl::{OFlag, at_rawfd}; +use crate::fcntl::{at_rawfd, OFlag}; use crate::unistd::{close, read, write}; +use crate::{NixPath, Result}; use std::marker::PhantomData; -use std::mem::{MaybeUninit, size_of}; +use std::mem::{size_of, MaybeUninit}; use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, OwnedFd, RawFd}; use std::ptr; @@ -288,11 +288,16 @@ impl Fanotify { /// Returns a Result containing a Fanotify instance. /// /// For more information, see [fanotify_init(2)](https://man7.org/linux/man-pages/man7/fanotify_init.2.html). - pub fn init(flags: InitFlags, event_f_flags: EventFFlags) -> Result { + pub fn init( + flags: InitFlags, + event_f_flags: EventFFlags, + ) -> Result { let res = Errno::result(unsafe { libc::fanotify_init(flags.bits(), event_f_flags.bits()) }); - res.map(|fd| Fanotify { fd: unsafe { OwnedFd::from_raw_fd(fd) }}) + res.map(|fd| Fanotify { + fd: unsafe { OwnedFd::from_raw_fd(fd) }, + }) } /// Add, remove, or modify an fanotify mark on a filesystem object. @@ -386,22 +391,21 @@ impl Fanotify { /// available on a group that has been initialized with the flag /// `InitFlags::FAN_NONBLOCK`, thus making this method nonblocking. pub fn write_response(&self, response: FanotifyResponse) -> Result<()> { - write( - self.fd.as_fd(), - unsafe { - std::slice::from_raw_parts( - (&response.inner as *const libc::fanotify_response).cast(), - size_of::(), - ) - }, - )?; + write(self.fd.as_fd(), unsafe { + std::slice::from_raw_parts( + (&response.inner as *const libc::fanotify_response).cast(), + size_of::(), + ) + })?; Ok(()) } } impl FromRawFd for Fanotify { unsafe fn from_raw_fd(fd: RawFd) -> Self { - Fanotify { fd: unsafe { OwnedFd::from_raw_fd(fd) }} + Fanotify { + fd: unsafe { OwnedFd::from_raw_fd(fd) }, + } } } diff --git a/src/sys/ptrace/bsd.rs b/src/sys/ptrace/bsd.rs index 69de590ace..086e32dcaf 100644 --- a/src/sys/ptrace/bsd.rs +++ b/src/sys/ptrace/bsd.rs @@ -68,7 +68,7 @@ unsafe fn ptrace_other( addr, data, )) - .map(|_| 0) + .map(|_| 0) } } diff --git a/src/sys/sendfile.rs b/src/sys/sendfile.rs index 6e2e0ace90..546664cf2e 100644 --- a/src/sys/sendfile.rs +++ b/src/sys/sendfile.rs @@ -22,7 +22,12 @@ use crate::Result; /// /// For more information, see [the sendfile(2) man page.](https://man7.org/linux/man-pages/man2/sendfile.2.html) for Linux, /// see [the sendfile(2) man page.](https://docs.oracle.com/cd/E88353_01/html/E37843/sendfile-3c.html) for Solaris. -#[cfg(any(target_os = "android", target_os = "linux", target_os = "solaris", target_os = "illumos"))] +#[cfg(any( + target_os = "android", + target_os = "linux", + target_os = "solaris", + target_os = "illumos", +))] pub fn sendfile( out_fd: F1, in_fd: F2, diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs index 319876f4c2..5c4bb9bf06 100644 --- a/src/sys/socket/addr.rs +++ b/src/sys/socket/addr.rs @@ -251,10 +251,7 @@ pub enum AddressFamily { #[cfg(bsd)] Hylink = libc::AF_HYLINK, /// Link layer interface - #[cfg(any( - bsd, - target_os = "illumos", - ))] + #[cfg(any(bsd, target_os = "illumos"))] Link = libc::AF_LINK, /// connection-oriented IP, aka ST II #[cfg(bsd)] @@ -293,10 +290,7 @@ impl AddressFamily { libc::PF_ROUTE => Some(AddressFamily::Route), #[cfg(linux_android)] libc::AF_PACKET => Some(AddressFamily::Packet), - #[cfg(any( - bsd, - target_os = "illumos", - ))] + #[cfg(any(bsd, target_os = "illumos"))] libc::AF_LINK => Some(AddressFamily::Link), #[cfg(any( target_os = "android", @@ -863,11 +857,7 @@ impl SockaddrIn { /// Creates a new socket address from IPv4 octets and a port number. pub fn new(a: u8, b: u8, c: u8, d: u8, port: u16) -> Self { Self(libc::sockaddr_in { - #[cfg(any( - bsd, - target_os = "aix", - target_os = "haiku", - ))] + #[cfg(any(bsd, target_os = "aix", target_os = "haiku"))] sin_len: Self::size() as u8, sin_family: AddressFamily::Inet as sa_family_t, sin_port: u16::to_be(port), @@ -936,11 +926,7 @@ impl fmt::Display for SockaddrIn { impl From for SockaddrIn { fn from(addr: net::SocketAddrV4) -> Self { Self(libc::sockaddr_in { - #[cfg(any( - bsd, - target_os = "haiku", - target_os = "hermit", - ))] + #[cfg(any(bsd, target_os = "haiku", target_os = "hermit"))] sin_len: mem::size_of::() as u8, sin_family: AddressFamily::Inet as sa_family_t, sin_port: addr.port().to_be(), // network byte order @@ -1060,11 +1046,7 @@ impl From for SockaddrIn6 { fn from(addr: net::SocketAddrV6) -> Self { #[allow(clippy::needless_update)] // It isn't needless on Illumos Self(libc::sockaddr_in6 { - #[cfg(any( - bsd, - target_os = "haiku", - target_os = "hermit", - ))] + #[cfg(any(bsd, target_os = "haiku", target_os = "hermit"))] sin6_len: mem::size_of::() as u8, sin6_family: AddressFamily::Inet6 as sa_family_t, sin6_port: addr.port().to_be(), // network byte order @@ -1198,15 +1180,11 @@ impl SockaddrLike for SockaddrStorage { libc::AF_INET6 => unsafe { SockaddrIn6::from_raw(addr, l).map(|sin6| Self { sin6 }) }, - #[cfg(any( - bsd, - target_os = "illumos", - target_os = "haiku", - ))] + #[cfg(any(bsd, target_os = "illumos", target_os = "haiku"))] #[cfg(feature = "net")] libc::AF_LINK => unsafe { LinkAddr::from_raw(addr, l).map(|dl| Self { dl }) - } + }, #[cfg(linux_android)] libc::AF_NETLINK => unsafe { NetlinkAddr::from_raw(addr, l).map(|nl| Self { nl }) @@ -1219,12 +1197,16 @@ impl SockaddrLike for SockaddrStorage { #[cfg(feature = "net")] libc::AF_PACKET => unsafe { LinkAddr::from_raw(addr, l).map(|dl| Self { dl }) - } + }, #[cfg(all(feature = "ioctl", apple_targets))] libc::AF_SYSTEM => unsafe { SysControlAddr::from_raw(addr, l).map(|sctl| Self { sctl }) - } - #[cfg(any(target_os = "android", target_os = "linux", target_os = "macos" ))] + }, + #[cfg(any( + target_os = "android", + target_os = "linux", + target_os = "macos", + ))] libc::AF_VSOCK => unsafe { VsockAddr::from_raw(addr, l).map(|vsock| Self { vsock }) }, @@ -1368,10 +1350,7 @@ impl SockaddrStorage { as_link_addr, as_link_addr_mut, LinkAddr, AddressFamily::Packet, libc::sockaddr_ll, dl} - #[cfg(any( - bsd, - target_os = "illumos", - ))] + #[cfg(any(bsd, target_os = "illumos"))] #[cfg(feature = "net")] accessors! { as_link_addr, as_link_addr_mut, LinkAddr, @@ -1425,10 +1404,7 @@ impl fmt::Display for SockaddrStorage { libc::AF_INET => self.sin.fmt(f), #[cfg(feature = "net")] libc::AF_INET6 => self.sin6.fmt(f), - #[cfg(any( - bsd, - target_os = "illumos", - ))] + #[cfg(any(bsd, target_os = "illumos"))] #[cfg(feature = "net")] libc::AF_LINK => self.dl.fmt(f), #[cfg(linux_android)] @@ -1498,10 +1474,7 @@ impl Hash for SockaddrStorage { libc::AF_INET => self.sin.hash(s), #[cfg(feature = "net")] libc::AF_INET6 => self.sin6.hash(s), - #[cfg(any( - bsd, - target_os = "illumos", - ))] + #[cfg(any(bsd, target_os = "illumos"))] #[cfg(feature = "net")] libc::AF_LINK => self.dl.hash(s), #[cfg(linux_android)] @@ -1539,10 +1512,7 @@ impl PartialEq for SockaddrStorage { (libc::AF_INET, libc::AF_INET) => self.sin == other.sin, #[cfg(feature = "net")] (libc::AF_INET6, libc::AF_INET6) => self.sin6 == other.sin6, - #[cfg(any( - bsd, - target_os = "illumos", - ))] + #[cfg(any(bsd, target_os = "illumos"))] #[cfg(feature = "net")] (libc::AF_LINK, libc::AF_LINK) => self.dl == other.dl, #[cfg(linux_android)] @@ -1980,12 +1950,7 @@ mod datalink { } } -#[cfg(any( - bsd, - target_os = "illumos", - target_os = "haiku", - target_os = "aix", -))] +#[cfg(any(bsd, target_os = "illumos", target_os = "haiku", target_os = "aix"))] mod datalink { feature! { #![feature = "net"]