diff options
Diffstat (limited to 'src/sys/socket/mod.rs')
-rw-r--r-- | src/sys/socket/mod.rs | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index e041e6b6..645dfe41 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -50,17 +50,8 @@ pub use self::multicast::{ }; pub use self::consts::*; -#[cfg(any(not(target_os = "linux"), not(target_arch = "x86")))] pub use libc::sockaddr_storage; -// Working around rust-lang/rust#23425 -#[cfg(all(target_os = "linux", target_arch = "x86"))] -pub struct sockaddr_storage { - pub ss_family: sa_family_t, - pub __ss_align: u32, - pub __ss_pad2: [u8; 120], -} - #[derive(Clone, Copy, PartialEq, Eq, Debug)] #[repr(i32)] pub enum SockType { @@ -238,8 +229,13 @@ impl<'a> ControlMessage<'a> { let padlen = cmsg_align(mem::size_of_val(&cmsg)) - mem::size_of_val(&cmsg); - let buf2 = &mut &mut buf[padlen..]; - copy_bytes(fds, buf2); + + let mut tmpbuf = &mut [][..]; + mem::swap(&mut tmpbuf, buf); + let (_padding, mut remainder) = tmpbuf.split_at_mut(padlen); + mem::swap(buf, &mut remainder); + + copy_bytes(fds, buf); }, ControlMessage::Unknown(UnknownCmsg(orig_cmsg, bytes)) => { copy_bytes(orig_cmsg, buf); |