Skip to content
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

PollFd should be repr(transparent) #1241

Closed
eduardosm opened this issue May 16, 2020 · 1 comment · Fixed by #1243
Closed

PollFd should be repr(transparent) #1241

eduardosm opened this issue May 16, 2020 · 1 comment · Fixed by #1243

Comments

@eduardosm
Copy link

Given the way PollFd is passed to the FFI poll function (.as_mut_ptr() as *mut libc::pollfd), the struct should be repr(transparent), so Rust will guarantee that PollFd has the same layout as libc::pollfd.

@asomers
Copy link
Member

asomers commented May 16, 2020

Yep, you're right! Nix predates repr(transparent), so there probably other places that need to be updated, too.

bors bot added a commit that referenced this issue May 16, 2020
1243: Apply `repr(transparent)` to several FFI types r=asomers a=asomers

repr(transparent) is required in order to safely cast between an FFI
type and its NewType.  This commit applies that attribute to PollFd,
EpollEvent, IpMembershipRequest, Ipv6MembershipRequest, TimeVal, and
IoVec.

Fixes #1241

Co-authored-by: Alan Somers <asomers@gmail.com>
@bors bors bot closed this as completed in b920333 May 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants