diff options
author | Steven Engler <opara@cs.georgetown.edu> | 2022-11-07 18:25:27 -0500 |
---|---|---|
committer | Steven Engler <opara@cs.georgetown.edu> | 2022-11-21 12:03:11 -0500 |
commit | 49bab984ee75391f37816eb722bbad9b7ae92b1c (patch) | |
tree | 9f1a3e005ca5bd3956f54192aa38b095d0a37b75 /src/sys | |
parent | 8884ea38ec80d838138070e941c080b0b573575a (diff) | |
download | nix-49bab984ee75391f37816eb722bbad9b7ae92b1c.zip |
fixup! Added better support for unnamed unix socket addrs
Make Linux-only
Diffstat (limited to 'src/sys')
-rw-r--r-- | src/sys/socket/addr.rs | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs index f051d205..34138efc 100644 --- a/src/sys/socket/addr.rs +++ b/src/sys/socket/addr.rs @@ -886,25 +886,16 @@ impl UnixAddr { } /// Create a new `sockaddr_un` representing an "unnamed" unix socket address. + #[cfg(any(target_os = "android", target_os = "linux"))] + #[cfg_attr(docsrs, doc(cfg(all())))] pub fn new_unnamed() -> UnixAddr { - #[allow(unused)] - let mut ret = libc::sockaddr_un { + let ret = libc::sockaddr_un { sun_family: AddressFamily::Unix as sa_family_t, .. unsafe { mem::zeroed() } }; let sun_len: u8 = offset_of!(libc::sockaddr_un, sun_path).try_into().unwrap(); - #[cfg(any(target_os = "dragonfly", - target_os = "freebsd", - target_os = "ios", - target_os = "macos", - target_os = "netbsd", - target_os = "openbsd"))] - { - ret.sun_len = sun_len; - } - unsafe { UnixAddr::from_raw_parts(ret, sun_len) } } @@ -965,6 +956,8 @@ impl UnixAddr { } /// Check if this address is an "unnamed" unix socket address. + #[cfg(any(target_os = "android", target_os = "linux"))] + #[cfg_attr(docsrs, doc(cfg(all())))] #[inline] pub fn is_unnamed(&self) -> bool { matches!(self.kind(), UnixAddrKind::Unnamed) |