diff options
Diffstat (limited to 'src/sys')
-rw-r--r-- | src/sys/event.rs | 6 | ||||
-rw-r--r-- | src/sys/personality.rs | 5 | ||||
-rw-r--r-- | src/sys/socket/addr.rs | 19 | ||||
-rw-r--r-- | src/sys/socket/mod.rs | 10 | ||||
-rw-r--r-- | src/sys/stat.rs | 4 | ||||
-rw-r--r-- | src/sys/statvfs.rs | 1 | ||||
-rw-r--r-- | src/sys/termios.rs | 6 | ||||
-rw-r--r-- | src/sys/time.rs | 2 |
8 files changed, 30 insertions, 23 deletions
diff --git a/src/sys/event.rs b/src/sys/event.rs index 5dcf121a..ec7f7e27 100644 --- a/src/sys/event.rs +++ b/src/sys/event.rs @@ -71,7 +71,7 @@ impl Kqueue { timeout as *const timespec } else { ptr::null() - } + }, ) }; Errno::result(res).map(|r| r as usize) @@ -86,7 +86,7 @@ impl Kqueue { target_os = "openbsd" ))] type type_of_udata = *mut libc::c_void; -#[cfg(any(target_os = "netbsd"))] +#[cfg(target_os = "netbsd")] type type_of_udata = intptr_t; #[cfg(target_os = "netbsd")] @@ -171,7 +171,7 @@ libc_enum! { ))] #[doc(hidden)] pub type type_of_event_flag = u16; -#[cfg(any(target_os = "netbsd"))] +#[cfg(target_os = "netbsd")] #[doc(hidden)] pub type type_of_event_flag = u32; libc_bitflags! { diff --git a/src/sys/personality.rs b/src/sys/personality.rs index f295a05f..30231dd7 100644 --- a/src/sys/personality.rs +++ b/src/sys/personality.rs @@ -80,7 +80,10 @@ pub fn get() -> Result<Persona> { /// /// Example: /// -/// ``` +// Disable test on aarch64 until we know why it fails. +// https://github.com/nix-rust/nix/issues/2060 +#[cfg_attr(target_arch = "aarch64", doc = " ```no_run")] +#[cfg_attr(not(target_arch = "aarch64"), doc = " ```")] /// # use nix::sys::personality::{self, Persona}; /// let mut pers = personality::get().unwrap(); /// assert!(!pers.contains(Persona::ADDR_NO_RANDOMIZE)); diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs index 88bd6f5a..0517615e 100644 --- a/src/sys/socket/addr.rs +++ b/src/sys/socket/addr.rs @@ -39,18 +39,17 @@ use std::{fmt, mem, net, ptr, slice}; /// Convert a std::net::Ipv4Addr into the libc form. #[cfg(feature = "net")] pub(crate) const fn ipv4addr_to_libc(addr: net::Ipv4Addr) -> libc::in_addr { - static_assertions::assert_eq_size!(net::Ipv4Addr, libc::in_addr); - // Safe because both types have the same memory layout, and no fancy Drop - // impls. - unsafe { mem::transmute(addr) } + libc::in_addr { + s_addr: u32::from_ne_bytes(addr.octets()) + } } /// Convert a std::net::Ipv6Addr into the libc form. #[cfg(feature = "net")] pub(crate) const fn ipv6addr_to_libc(addr: &net::Ipv6Addr) -> libc::in6_addr { - static_assertions::assert_eq_size!(net::Ipv6Addr, libc::in6_addr); - // Safe because both are Newtype wrappers around the same libc type - unsafe { mem::transmute(*addr) } + libc::in6_addr { + s6_addr: addr.octets() + } } /// These constants specify the protocol family to be used @@ -485,6 +484,7 @@ enum UnixAddrKind<'a> { } impl<'a> UnixAddrKind<'a> { /// Safety: sun & sun_len must be valid + #[allow(clippy::unnecessary_cast)] // Not unnecessary on all platforms unsafe fn get(sun: &'a libc::sockaddr_un, sun_len: u8) -> Self { assert!(sun_len as usize >= offset_of!(libc::sockaddr_un, sun_path)); let path_len = @@ -521,6 +521,7 @@ impl<'a> UnixAddrKind<'a> { impl UnixAddr { /// Create a new sockaddr_un representing a filesystem path. + #[allow(clippy::unnecessary_cast)] // Not unnecessary on all platforms pub fn new<P: ?Sized + NixPath>(path: &P) -> Result<UnixAddr> { path.with_nix_path(|cstr| unsafe { let mut ret = libc::sockaddr_un { @@ -568,6 +569,7 @@ impl UnixAddr { /// processes to communicate with processes having a different filesystem view. #[cfg(any(target_os = "android", target_os = "linux"))] #[cfg_attr(docsrs, doc(cfg(all())))] + #[allow(clippy::unnecessary_cast)] // Not unnecessary on all platforms pub fn new_abstract(path: &[u8]) -> Result<UnixAddr> { unsafe { let mut ret = libc::sockaddr_un { @@ -990,9 +992,6 @@ impl SockaddrLike for () { } /// An IPv4 socket address -// This is identical to net::SocketAddrV4. But the standard library -// doesn't allow direct access to the libc fields, which we need. So we -// reimplement it here. #[cfg(feature = "net")] #[repr(transparent)] #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index 4ca12997..3abcb033 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -247,14 +247,18 @@ libc_bitflags! { SOF_TIMESTAMPING_SOFTWARE; /// Report hardware timestamps as generated by SOF_TIMESTAMPING_TX_HARDWARE when available. SOF_TIMESTAMPING_RAW_HARDWARE; - /// Collect transmiting timestamps as reported by hardware + /// Collect transmitting timestamps as reported by hardware SOF_TIMESTAMPING_TX_HARDWARE; - /// Collect transmiting timestamps as reported by software + /// Collect transmitting timestamps as reported by software SOF_TIMESTAMPING_TX_SOFTWARE; /// Collect receiving timestamps as reported by hardware SOF_TIMESTAMPING_RX_HARDWARE; /// Collect receiving timestamps as reported by software SOF_TIMESTAMPING_RX_SOFTWARE; + /// Generate a unique identifier along with each transmitted packet + SOF_TIMESTAMPING_OPT_ID; + /// Return transmit timestamps alongside an empty packet instead of the original packet + SOF_TIMESTAMPING_OPT_TSONLY; } } @@ -2239,7 +2243,7 @@ pub fn recvfrom<T: SockaddrLike>( Ok(( ret, T::from_raw( - addr.assume_init().as_ptr() as *const sockaddr, + addr.assume_init().as_ptr(), Some(len), ), )) diff --git a/src/sys/stat.rs b/src/sys/stat.rs index 78203bfb..7e51c03a 100644 --- a/src/sys/stat.rs +++ b/src/sys/stat.rs @@ -177,7 +177,7 @@ pub fn mknod<P: ?Sized + NixPath>( dev: dev_t, ) -> Result<()> { let res = path.with_nix_path(|cstr| unsafe { - libc::mknod(cstr.as_ptr(), kind.bits | perm.bits() as mode_t, dev) + libc::mknod(cstr.as_ptr(), kind.bits() | perm.bits() as mode_t, dev) })?; Errno::result(res).map(drop) @@ -202,7 +202,7 @@ pub fn mknodat<P: ?Sized + NixPath>( libc::mknodat( dirfd, cstr.as_ptr(), - kind.bits | perm.bits() as mode_t, + kind.bits() | perm.bits() as mode_t, dev, ) })?; diff --git a/src/sys/statvfs.rs b/src/sys/statvfs.rs index c2c86624..35424e5e 100644 --- a/src/sys/statvfs.rs +++ b/src/sys/statvfs.rs @@ -12,7 +12,6 @@ use crate::{errno::Errno, NixPath, Result}; #[cfg(not(target_os = "redox"))] libc_bitflags!( /// File system mount Flags - #[repr(C)] #[derive(Default)] pub struct FsFlags: c_ulong { /// Read Only diff --git a/src/sys/termios.rs b/src/sys/termios.rs index b0286f51..af29d64d 100644 --- a/src/sys/termios.rs +++ b/src/sys/termios.rs @@ -309,7 +309,7 @@ impl Termios { let termios = *self.inner.borrow_mut(); self.input_flags = InputFlags::from_bits_truncate(termios.c_iflag); self.output_flags = OutputFlags::from_bits_truncate(termios.c_oflag); - self.control_flags = ControlFlags::from_bits_truncate(termios.c_cflag); + self.control_flags = ControlFlags::from_bits_retain(termios.c_cflag); self.local_flags = LocalFlags::from_bits_truncate(termios.c_lflag); self.control_chars = termios.c_cc; #[cfg(any( @@ -355,9 +355,9 @@ libc_enum! { /// enum. /// /// B0 is special and will disable the port. - #[cfg_attr(all(any(target_os = "haiku"), target_pointer_width = "64"), repr(u8))] + #[cfg_attr(target_os = "haiku", repr(u8))] #[cfg_attr(all(any(target_os = "ios", target_os = "macos"), target_pointer_width = "64"), repr(u64))] - #[cfg_attr(not(all(any(target_os = "ios", target_os = "macos", target_os = "haiku"), target_pointer_width = "64")), repr(u32))] + #[cfg_attr(all(not(all(any(target_os = "ios", target_os = "macos"), target_pointer_width = "64")), not(target_os = "haiku")), repr(u32))] #[non_exhaustive] pub enum BaudRate { B0, diff --git a/src/sys/time.rs b/src/sys/time.rs index 30ee5fd1..a0160e21 100644 --- a/src/sys/time.rs +++ b/src/sys/time.rs @@ -91,6 +91,7 @@ pub(crate) mod timer { #[cfg(any(target_os = "android", target_os = "linux"))] bitflags! { /// Flags that are used for arming the timer. + #[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub struct TimerSetTimeFlags: libc::c_int { const TFD_TIMER_ABSTIME = libc::TFD_TIMER_ABSTIME; const TFD_TIMER_CANCEL_ON_SET = libc::TFD_TIMER_CANCEL_ON_SET; @@ -104,6 +105,7 @@ pub(crate) mod timer { ))] bitflags! { /// Flags that are used for arming the timer. + #[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub struct TimerSetTimeFlags: libc::c_int { const TFD_TIMER_ABSTIME = libc::TIMER_ABSTIME; } |