-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rely on libc for correct integer types in os/unix/net/ancillary.rs. #86357
Conversation
r? @dtolnay (rust-highfive has picked a reviewer for you, use r? to override) |
if #[cfg(any( | ||
target_os = "android", | ||
all(target_os = "linux", target_env = "gnu"), | ||
all(target_os = "linux", target_env = "uclibc"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This cfg
is different than the others.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some consideration, I decided to remove the cfg_if
entirely and rely on libc to have the correct struct definition instead. If something turns out to be incorrect, it only needs to be fixed in one place :)
Nice! The fewer of these |
9e09304
to
d892738
Compare
This comment has been minimized.
This comment has been minimized.
d892738
to
259bf5f
Compare
let cmsg_len_zero = libc::CMSG_LEN(0) as usize; | ||
let data_len = (*cmsg).cmsg_len as usize - cmsg_len_zero; | ||
let data = libc::CMSG_DATA(cmsg).cast(); | ||
let data = from_raw_parts(data, data_len as usize); | ||
let data = from_raw_parts(data, data_len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just always be a usize
, because it's only ever passed to slice::from_raw_parts
.
Thanks! @bors r+ |
📌 Commit 259bf5f has been approved by |
Rollup of 6 pull requests Successful merges: - rust-lang#85925 (Linear interpolation) - rust-lang#86202 (Specialize `io::Bytes::size_hint` for more types) - rust-lang#86357 (Rely on libc for correct integer types in os/unix/net/ancillary.rs.) - rust-lang#86388 (Make `s` pre-interned) - rust-lang#86401 (Fix ICE when using `#[doc(keyword = "...")]` on non-items) - rust-lang#86405 (Add incr-comp note for 1.53.0 relnotes) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This PR is a small maintainability improvement. It simplifies
unix/net/ancillary.rs
instd
by removing thecfg_ifs
for casting to the correct integer type, and just rely on libc to define the struct correctly.