| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::markerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/::PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#; |
| 2 | |
| 3 | use craterust-analyzer cargo timestamped-socket 0.2.2 crate/::socketrust-analyzer cargo timestamped-socket 0.2.2 socket/::Timestamprust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp#; |
| 4 | |
| 5 | pub(craterust-analyzer cargo timestamped-socket 0.2.2 crate/) const fn control_message_spacerust-analyzer cargo timestamped-socket 0.2.2 control_message/control_message_space().<T>() -> usize { |
| 6 | // Safety: CMSG_SPACE is safe to call |
| 7 | (unsafe { libcrust-analyzer cargo libc 0.2.152 crate/::CMSG_SPACErust-analyzer cargo libc 0.2.152 unix/linux_like/CMSG_SPACE().((stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<T>()) as _) }) as usize |
| 8 | } |
| 9 | |
| 10 | pub(craterust-analyzer cargo timestamped-socket 0.2.2 crate/) enum MessageQueuerust-analyzer cargo timestamped-socket 0.2.2 control_message/MessageQueue# { |
| 11 | Normalrust-analyzer cargo timestamped-socket 0.2.2 control_message/MessageQueue#Normal#, |
| 12 | #[cfg(target_os = "linux")] |
| 13 | Errorrust-analyzer cargo timestamped-socket 0.2.2 control_message/MessageQueue#Error#, |
| 14 | } |
| 15 | |
| 16 | // Invariants: |
| 17 | // self.mhdr points to a valid libc::msghdr with a valid control |
| 18 | // message region. |
| 19 | // self.next_msg points to one of the control messages |
| 20 | // in the region described by self.mhdr or is NULL |
| 21 | // |
| 22 | // These invariants are guaranteed from the safety conditions on |
| 23 | // calling ControlMessageIterator::new, the fact that next preserves |
| 24 | // these invariants and that the fields of ControlMessageIterator |
| 25 | // are not modified outside these two functions. |
| 26 | pub(craterust-analyzer cargo timestamped-socket 0.2.2 crate/) struct ControlMessageIteratorrust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessageIterator#<'a> { |
| 27 | mhdrrust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessageIterator#mhdr.: libcrust-analyzer cargo libc 0.2.152 crate/::msghdrrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/gnu/msghdr#, |
| 28 | next_msgrust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessageIterator#next_msg.: *const libcrust-analyzer cargo libc 0.2.152 crate/::cmsghdrrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/gnu/cmsghdr#, |
| 29 | phantomrust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessageIterator#phantom.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<&'a [u8]>, |
| 30 | } |
| 31 | |
| 32 | impl<'a> ControlMessageIteratorrust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessageIterator#<'a> { |
| 33 | // Safety assumptions: |
| 34 | // mhdr has a control and controllen field |
| 35 | // that together describe a memory region |
| 36 | // with lifetime 'a containing valid control |
| 37 | // messages |
| 38 | pub unsafe fn newrust-analyzer cargo timestamped-socket 0.2.2 control_message/impl#[`ControlMessageIterator<'a>`]new().(mhdr: libcrust-analyzer cargo libc 0.2.152 crate/::msghdrrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/gnu/msghdr#) -> Selfrust-analyzer cargo timestamped-socket 0.2.2 control_message/impl#[`ControlMessageIterator<'a>`] { |
| 39 | // Safety: |
| 40 | // mhdr's control and controllen fields are valid and point |
| 41 | // to valid control messages. |
| 42 | let current_msg = unsafe { libcrust-analyzer cargo libc 0.2.152 crate/::CMSG_FIRSTHDRrust-analyzer cargo libc 0.2.152 unix/linux_like/CMSG_FIRSTHDR().(&mhdr) }; |
| 43 | |
| 44 | // Invariant preservation: |
| 45 | // The safety assumptions guaranteed by the caller ensure |
| 46 | // that mhdr points to a valid region with valid control |
| 47 | // messages. CMSG_FIRSTHDR is then guaranteed to either |
| 48 | // return the pointer to the first valid control message |
| 49 | // in that region, or NULL if the region is empty. |
| 50 | Selfrust-analyzer cargo timestamped-socket 0.2.2 control_message/impl#[`ControlMessageIterator<'a>`] { |
| 51 | mhdrrust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessageIterator#mhdr., |
| 52 | next_msgrust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessageIterator#next_msg.: current_msg, |
| 53 | phantomrust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessageIterator#phantom.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | pub(craterust-analyzer cargo timestamped-socket 0.2.2 crate/) enum ControlMessagerust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage# { |
| 59 | Timestampingrust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#Timestamping# { |
| 60 | softwarerust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#Timestamping#software.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Timestamprust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp#>, |
| 61 | hardwarerust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#Timestamping#hardware.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Timestamprust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp#>, |
| 62 | }, |
| 63 | #[cfg(target_os = "linux")] |
| 64 | ReceiveErrorrust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#ReceiveError#(libcrust-analyzer cargo libc 0.2.152 crate/::sock_extended_errrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/sock_extended_err#), |
| 65 | Otherrust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#Other#(libcrust-analyzer cargo libc 0.2.152 crate/::cmsghdrrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/gnu/cmsghdr#), |
| 66 | } |
| 67 | |
| 68 | #[cfg(target_os = "linux")] |
| 69 | const SCM_TIMESTAMP_NSrust-analyzer cargo timestamped-socket 0.2.2 control_message/SCM_TIMESTAMP_NS.: libcrust-analyzer cargo libc 0.2.152 crate/::c_intrust-analyzer cargo libc 0.2.152 unix/c_int# = libcrust-analyzer cargo libc 0.2.152 crate/::SCM_TIMESTAMPNSrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/arch/generic/SCM_TIMESTAMPNS.; |
| 70 | #[cfg(target_os = "freebsd")] |
| 71 | const SCM_TIMESTAMP_NS: libcrust-analyzer cargo libc 0.2.152 crate/::c_intrust-analyzer cargo libc 0.2.152 unix/c_int# = libcrust-analyzer cargo libc 0.2.152 crate/::SCM_REALTIME; |
| 72 | |
| 73 | #[cfg(target_os = "linux")] |
| 74 | const PACKET_TX_TIMESTAMPrust-analyzer cargo timestamped-socket 0.2.2 control_message/PACKET_TX_TIMESTAMP.: libcrust-analyzer cargo libc 0.2.152 crate/::c_intrust-analyzer cargo libc 0.2.152 unix/c_int# = 16; |
| 75 | |
| 76 | impl<'a> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for ControlMessageIteratorrust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessageIterator#<'a> { |
| 77 | type Itemrust-analyzer cargo timestamped-socket 0.2.2 control_message/impl#[`ControlMessageIterator<'a>`][Iterator]Item# = ControlMessagerust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#; |
| 78 | |
| 79 | fn nextrust-analyzer cargo timestamped-socket 0.2.2 control_message/impl#[`ControlMessageIterator<'a>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo timestamped-socket 0.2.2 control_message/impl#[`ControlMessageIterator<'a>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 80 | // Safety: |
| 81 | // By the invariants, self.current_msg either points to a valid control message |
| 82 | // or is NULL |
| 83 | let current_msg = unsafe { self.next_msgrust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessageIterator#next_msg..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/const_ptr/impl#[`*const T`]as_ref().() }?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().; |
| 84 | |
| 85 | // Safety: |
| 86 | // Invariants ensure that self.mhdr points to a valid libc::msghdr with a valid |
| 87 | // control message region, and that self.next_msg either points to a |
| 88 | // valid control message or is NULL. |
| 89 | // The previous statement would have returned if self.next_msg were NULL, |
| 90 | // therefore both passed pointers are valid for use with CMSG_NXTHDR |
| 91 | // Invariant preservation: |
| 92 | // CMSG_NXTHDR returns either a pointer to the next valid control message in the |
| 93 | // control message region described by self.mhdr, or NULL |
| 94 | self.next_msgrust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessageIterator#next_msg. = unsafe { libcrust-analyzer cargo libc 0.2.152 crate/::CMSG_NXTHDRrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/CMSG_NXTHDR().(&self.mhdrrust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessageIterator#mhdr., self.next_msgrust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessageIterator#next_msg.) }; |
| 95 | |
| 96 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(match (current_msg.cmsg_levelrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/gnu/cmsghdr#cmsg_level., current_msg.cmsg_typerust-analyzer cargo libc 0.2.152 unix/linux_like/linux/gnu/cmsghdr#cmsg_type.) { |
| 97 | #[cfg(target_os = "linux")] |
| 98 | (libcrust-analyzer cargo libc 0.2.152 crate/::SOL_SOCKETrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/arch/generic/SOL_SOCKET., libcrust-analyzer cargo libc 0.2.152 crate/::SCM_TIMESTAMPINGrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/arch/generic/SCM_TIMESTAMPING.) => { |
| 99 | // Safety: |
| 100 | // current_msg was constructed from a pointer that pointed to a valid control message. |
| 101 | // SO_TIMESTAMPING always has 3 timespecs in the data |
| 102 | let cmsg_data = |
| 103 | unsafe { libcrust-analyzer cargo libc 0.2.152 crate/::CMSG_DATArust-analyzer cargo libc 0.2.152 unix/linux_like/CMSG_DATA().(current_msg) } as *const [libcrust-analyzer cargo libc 0.2.152 crate/::timespecrust-analyzer cargo libc 0.2.152 unix/timespec#; 3]; |
| 104 | |
| 105 | let [software, _, hardware] = unsafe { stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/::read_unalignedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/read_unaligned().(cmsg_data) }; |
| 106 | |
| 107 | // Both 0 indicates it is not present |
| 108 | let hardware = if hardware.tv_secrust-analyzer cargo libc 0.2.152 unix/timespec#tv_sec. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialEq<Self>`]ne().0 || hardware.tv_nsecrust-analyzer cargo libc 0.2.152 unix/timespec#tv_nsec. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialEq<Self>`]ne().0 { |
| 109 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Timestamprust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp#::from_timespecrust-analyzer cargo timestamped-socket 0.2.2 socket/impl#[Timestamp]from_timespec().(hardware)) |
| 110 | } else { |
| 111 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 112 | }; |
| 113 | |
| 114 | // Both 0 indicates it is not present |
| 115 | let software = if software.tv_secrust-analyzer cargo libc 0.2.152 unix/timespec#tv_sec. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialEq<Self>`]ne().0 || software.tv_nsecrust-analyzer cargo libc 0.2.152 unix/timespec#tv_nsec. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialEq<Self>`]ne().0 { |
| 116 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Timestamprust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp#::from_timespecrust-analyzer cargo timestamped-socket 0.2.2 socket/impl#[Timestamp]from_timespec().(software)) |
| 117 | } else { |
| 118 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 119 | }; |
| 120 | |
| 121 | ControlMessagerust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#::Timestampingrust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#Timestamping# { softwarerust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#Timestamping#software., hardwarerust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#Timestamping#hardware. } |
| 122 | } |
| 123 | |
| 124 | #[cfg(any(target_os = "linux", target_os = "freebsd"))] |
| 125 | (libcrust-analyzer cargo libc 0.2.152 crate/::SOL_SOCKETrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/arch/generic/SOL_SOCKET., SCM_TIMESTAMP_NSrust-analyzer cargo timestamped-socket 0.2.2 control_message/SCM_TIMESTAMP_NS.) => { |
| 126 | // Safety: |
| 127 | // current_msg was constructed from a pointer that pointed to a valid control message. |
| 128 | // SO_TIMESTAMPNS always has a timespec in the data |
| 129 | let cmsg_data = unsafe { libcrust-analyzer cargo libc 0.2.152 crate/::CMSG_DATArust-analyzer cargo libc 0.2.152 unix/linux_like/CMSG_DATA().(current_msg) } as *const libcrust-analyzer cargo libc 0.2.152 crate/::timespecrust-analyzer cargo libc 0.2.152 unix/timespec#; |
| 130 | |
| 131 | let timespec = unsafe { stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/::read_unalignedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/read_unaligned().(cmsg_data) }; |
| 132 | |
| 133 | ControlMessagerust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#::Timestampingrust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#Timestamping# { |
| 134 | softwarerust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#Timestamping#software.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Timestamprust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp#::from_timespecrust-analyzer cargo timestamped-socket 0.2.2 socket/impl#[Timestamp]from_timespec().(timespec)), |
| 135 | hardwarerust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#Timestamping#hardware.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | (libcrust-analyzer cargo libc 0.2.152 crate/::SOL_SOCKETrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/arch/generic/SOL_SOCKET., libcrust-analyzer cargo libc 0.2.152 crate/::SCM_TIMESTAMPrust-analyzer cargo libc 0.2.152 unix/linux_like/SCM_TIMESTAMP.) => { |
| 140 | // Safety: |
| 141 | // current_msg was constructed from a pointer that pointed to a valid control message. |
| 142 | // SO_TIMESTAMP always has a timeval in the data |
| 143 | let cmsg_data = unsafe { libcrust-analyzer cargo libc 0.2.152 crate/::CMSG_DATArust-analyzer cargo libc 0.2.152 unix/linux_like/CMSG_DATA().(current_msg) } as *const libcrust-analyzer cargo libc 0.2.152 crate/::timevalrust-analyzer cargo libc 0.2.152 unix/timeval#; |
| 144 | let timeval = unsafe { stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/::read_unalignedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/read_unaligned().(cmsg_data) }; |
| 145 | ControlMessagerust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#::Timestampingrust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#Timestamping# { |
| 146 | softwarerust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#Timestamping#software.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Timestamprust-analyzer cargo timestamped-socket 0.2.2 socket/Timestamp#::from_timevalrust-analyzer cargo timestamped-socket 0.2.2 socket/impl#[Timestamp]from_timeval().(timeval)), |
| 147 | hardwarerust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#Timestamping#hardware.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | #[cfg(target_os = "linux")] |
| 152 | (libcrust-analyzer cargo libc 0.2.152 crate/::SOL_IPrust-analyzer cargo libc 0.2.152 unix/linux_like/SOL_IP., libcrust-analyzer cargo libc 0.2.152 crate/::IP_RECVERRrust-analyzer cargo libc 0.2.152 unix/linux_like/IP_RECVERR.) |
| 153 | | (libcrust-analyzer cargo libc 0.2.152 crate/::SOL_IPV6rust-analyzer cargo libc 0.2.152 unix/linux_like/SOL_IPV6., libcrust-analyzer cargo libc 0.2.152 crate/::IPV6_RECVERRrust-analyzer cargo libc 0.2.152 unix/linux_like/IPV6_RECVERR.) |
| 154 | | (libcrust-analyzer cargo libc 0.2.152 crate/::SOL_PACKETrust-analyzer cargo libc 0.2.152 unix/linux_like/SOL_PACKET., PACKET_TX_TIMESTAMPrust-analyzer cargo timestamped-socket 0.2.2 control_message/PACKET_TX_TIMESTAMP.) => { |
| 155 | // this is part of how timestamps are reported. |
| 156 | // Safety: |
| 157 | // current_msg was constructed from a pointer that pointed to a valid |
| 158 | // control message. |
| 159 | // IP*_RECVERR always has a sock_extended_err in the data |
| 160 | let error = unsafe { |
| 161 | let ptr = libcrust-analyzer cargo libc 0.2.152 crate/::CMSG_DATArust-analyzer cargo libc 0.2.152 unix/linux_like/CMSG_DATA().(current_msg) as *const libcrust-analyzer cargo libc 0.2.152 crate/::sock_extended_errrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/sock_extended_err#; |
| 162 | stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/::read_unalignedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/read_unaligned().(ptr) |
| 163 | }; |
| 164 | |
| 165 | ControlMessagerust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#::ReceiveErrorrust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#ReceiveError#(error) |
| 166 | } |
| 167 | _ => ControlMessagerust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#::Otherrust-analyzer cargo timestamped-socket 0.2.2 control_message/ControlMessage#Other#(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().current_msg), |
| 168 | }) |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | pub(craterust-analyzer cargo timestamped-socket 0.2.2 crate/) fn zeroed_sockaddr_storagerust-analyzer cargo timestamped-socket 0.2.2 control_message/zeroed_sockaddr_storage().() -> libcrust-analyzer cargo libc 0.2.152 crate/::sockaddr_storagerust-analyzer cargo libc 0.2.152 unix/linux_like/sockaddr_storage# { |
| 173 | // a zeroed-out sockaddr storage is semantically valid, because a ss_family with |
| 174 | // value 0 is libc::AF_UNSPEC. Hence the rest of the data does not come with |
| 175 | // any constraints Safety: |
| 176 | // the MaybeUninit is zeroed before assumed to be initialized |
| 177 | unsafe { stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::MaybeUninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/MaybeUninit#::zeroedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]zeroed().().assume_initrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]assume_init().() } |
| 178 | } |
| 179 | |
| 180 | pub(craterust-analyzer cargo timestamped-socket 0.2.2 crate/) fn empty_msghdrrust-analyzer cargo timestamped-socket 0.2.2 control_message/empty_msghdr().() -> libcrust-analyzer cargo libc 0.2.152 crate/::msghdrrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/gnu/msghdr# { |
| 181 | // On `target_env = "musl"`, there are several private padding fields. |
| 182 | // the position of these padding fields depends on the system endianness, |
| 183 | // so keeping making them public does not really help. |
| 184 | // |
| 185 | // Safety: |
| 186 | // |
| 187 | // all fields are either integer or pointer types. For those types, 0 is a valid |
| 188 | // value |
| 189 | unsafe { stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::MaybeUninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/MaybeUninit#::<libcrust-analyzer cargo libc 0.2.152 crate/::msghdrrust-analyzer cargo libc 0.2.152 unix/linux_like/linux/gnu/msghdr#>::zeroedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]zeroed().().assume_initrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]assume_init().() } |
| 190 | } |