Rely on libc for correct integer types in os/unix/net/ancillary.rs.#86357
Merged
bors merged 1 commit intorust-lang:masterfrom Jun 18, 2021
Merged
Rely on libc for correct integer types in os/unix/net/ancillary.rs.#86357bors merged 1 commit intorust-lang:masterfrom
bors merged 1 commit intorust-lang:masterfrom
Conversation
Contributor
|
r? @dtolnay (rust-highfive has picked a reviewer for you, use r? to override) |
m-ou-se
reviewed
Jun 17, 2021
Member
There was a problem hiding this comment.
This cfg is different than the others.
Contributor
Author
There was a problem hiding this comment.
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 :)
Member
|
Nice! The fewer of these |
9e09304 to
d892738
Compare
This comment has been minimized.
This comment has been minimized.
d892738 to
259bf5f
Compare
de-vri-es
commented
Jun 17, 2021
Comment on lines
+309
to
+312
| 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); |
Contributor
Author
There was a problem hiding this comment.
This can just always be a usize, because it's only ever passed to slice::from_raw_parts.
Member
|
Thanks! @bors r+ |
Collaborator
|
📌 Commit 259bf5f has been approved by |
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jun 17, 2021
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is a small maintainability improvement. It simplifies
unix/net/ancillary.rsinstdby removing thecfg_ifsfor casting to the correct integer type, and just rely on libc to define the struct correctly.