diff options
author | Bryant Mairs <bryant@mai.rs> | 2017-02-28 11:05:10 -0800 |
---|---|---|
committer | Bryant Mairs <bryant@mai.rs> | 2017-03-02 09:52:33 -0800 |
commit | 80453b9139d5a035efaac2e963838676dcd04c37 (patch) | |
tree | 84504663f9bc529df624a3b595cb7c750dd00c1c | |
parent | 13deb619c3e0bdf490511cedd848e60633ca3b2d (diff) | |
download | nix-80453b9139d5a035efaac2e963838676dcd04c37.zip |
Remove revents from PollFd::new
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.
-rw-r--r-- | CHANGELOG.md | 3 | ||||
-rw-r--r-- | src/poll.rs | 4 | ||||
-rw-r--r-- | test/test_poll.rs | 2 |
3 files changed, 6 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 26c016f8..fe9f94dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/poll.rs b/src/poll.rs index 8a3de5f1..afc5bd9c 100644 --- a/src/poll.rs +++ b/src/poll.rs @@ -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(), }, } } diff --git a/test/test_poll.rs b/test/test_poll.rs index 13a95d2c..6d30f265 100644 --- a/test/test_poll.rs +++ b/test/test_poll.rs @@ -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); |