Skip to content

Commit

Permalink
Remove revents from PollFd::new
Browse files Browse the repository at this point in the history
revents is an output field so regardless of what value it is set to it
will be overwritten by many of the function calls that take a PollFd.
The only value that makes sense for the caller to pass in in
`EventFlags::empty()` so we just hardcode that instead of making the
caller do it.
  • Loading branch information
Susurrus committed Mar 2, 2017
1 parent 13deb61 commit 80453b9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Exposed all fcntl(2) operations at the module level, so they can be
imported direclty instead of via `FcntlArg` enum.
([#541](https://github.com/nix-rust/nix/pull/541))
- Removed `revents` argument from `PollFd::new()` as it's an output argument and
will be overwritten regardless of value.
([#542](https://github.com/nix-rust/nix/pull/542)

### Fixed
- Fixed multiple issues with Unix domain sockets on non-Linux OSes
Expand Down
4 changes: 2 additions & 2 deletions src/poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ pub struct PollFd {
}

impl PollFd {
pub fn new(fd: libc::c_int, events: EventFlags, revents: EventFlags) -> PollFd {
pub fn new(fd: libc::c_int, events: EventFlags) -> PollFd {
PollFd {
pollfd: libc::pollfd {
fd: fd,
events: events.bits(),
revents: revents.bits(),
revents: EventFlags::empty().bits(),
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/test_poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use nix::unistd::{write, pipe};
#[test]
fn test_poll() {
let (r, w) = pipe().unwrap();
let mut fds = [PollFd::new(r, POLLIN, EventFlags::empty())];
let mut fds = [PollFd::new(r, POLLIN)];

let nfds = poll(&mut fds, 100).unwrap();
assert_eq!(nfds, 0);
Expand Down

0 comments on commit 80453b9

Please sign in to comment.