Add `MSG_WAITFORONE.try_into().unwrap()` to deal with different type signature on musl libc (#29369)

* add try_into().unwrap() to deal with different type signature on musl libc

* add allow useless_conversion

* trailing whitespace

* cargo fmt
This commit is contained in:
Han Yang 2023-01-25 20:40:14 +08:00 committed by GitHub
parent 8f4bcf7fee
commit 7d286961ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 2 deletions

View File

@ -99,8 +99,17 @@ pub fn recv_mmsg(sock: &UdpSocket, packets: &mut [Packet]) -> io::Result</*num p
tv_sec: 1, tv_sec: 1,
tv_nsec: 0, tv_nsec: 0,
}; };
let nrecv = // TODO: remove .try_into().unwrap() once rust libc fixes recvmmsg types for musl
unsafe { libc::recvmmsg(sock_fd, &mut hdrs[0], count as u32, MSG_WAITFORONE, &mut ts) }; #[allow(clippy::useless_conversion)]
let nrecv = unsafe {
libc::recvmmsg(
sock_fd,
&mut hdrs[0],
count as u32,
MSG_WAITFORONE.try_into().unwrap(),
&mut ts,
)
};
let nrecv = if nrecv < 0 { let nrecv = if nrecv < 0 {
return Err(io::Error::last_os_error()); return Err(io::Error::last_os_error());
} else { } else {