Skip to content

Commit 80453b9

Browse files
committed
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.
1 parent 13deb61 commit 80453b9

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
9595
- Exposed all fcntl(2) operations at the module level, so they can be
9696
imported direclty instead of via `FcntlArg` enum.
9797
([#541](https://github.com/nix-rust/nix/pull/541))
98+
- Removed `revents` argument from `PollFd::new()` as it's an output argument and
99+
will be overwritten regardless of value.
100+
([#542](https://github.com/nix-rust/nix/pull/542)
98101

99102
### Fixed
100103
- Fixed multiple issues with Unix domain sockets on non-Linux OSes

src/poll.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ pub struct PollFd {
1313
}
1414

1515
impl PollFd {
16-
pub fn new(fd: libc::c_int, events: EventFlags, revents: EventFlags) -> PollFd {
16+
pub fn new(fd: libc::c_int, events: EventFlags) -> PollFd {
1717
PollFd {
1818
pollfd: libc::pollfd {
1919
fd: fd,
2020
events: events.bits(),
21-
revents: revents.bits(),
21+
revents: EventFlags::empty().bits(),
2222
},
2323
}
2424
}

test/test_poll.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use nix::unistd::{write, pipe};
44
#[test]
55
fn test_poll() {
66
let (r, w) = pipe().unwrap();
7-
let mut fds = [PollFd::new(r, POLLIN, EventFlags::empty())];
7+
let mut fds = [PollFd::new(r, POLLIN)];
88

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

0 commit comments

Comments
 (0)