diff options
author | arcnmx <arcnmx@users.noreply.github.com> | 2016-01-25 21:57:17 -0500 |
---|---|---|
committer | Kamal Marhubi <kamal@marhubi.com> | 2016-01-28 00:44:44 -0500 |
commit | 136bb454d98a9032843259e71f12d8e33cd90f27 (patch) | |
tree | 942872a1bad2de7b3417f248dda6d70b8ac01d54 /src/sys/event.rs | |
parent | 01e841679633b459470120a305ff22dd12138422 (diff) | |
download | nix-136bb454d98a9032843259e71f12d8e33cd90f27.zip |
Errno::result()
Diffstat (limited to 'src/sys/event.rs')
-rw-r--r-- | src/sys/event.rs | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/src/sys/event.rs b/src/sys/event.rs index 6498cb97..eb99f7d9 100644 --- a/src/sys/event.rs +++ b/src/sys/event.rs @@ -1,8 +1,7 @@ /* TOOD: Implement for other kqueue based systems */ -use {Error, Result}; -use errno::Errno; +use errno::{Errno, Result}; #[cfg(not(target_os = "netbsd"))] use libc::{timespec, time_t, c_int, c_long, uintptr_t}; #[cfg(target_os = "netbsd")] @@ -277,11 +276,7 @@ pub const EV_OOBAND: EventFlag = EV_FLAG1; pub fn kqueue() -> Result<RawFd> { let res = unsafe { ffi::kqueue() }; - if res < 0 { - return Err(Error::Sys(Errno::last())); - } - - Ok(res) + Errno::result(res) } pub fn kevent(kq: RawFd, @@ -314,11 +309,7 @@ pub fn kevent_ts(kq: RawFd, if let Some(ref timeout) = timeout_opt {timeout as *const timespec} else {ptr::null()}) }; - if res < 0 { - return Err(Error::Sys(Errno::last())); - } - - return Ok(res as usize) + Errno::result(res).map(|r| r as usize) } #[cfg(target_os = "netbsd")] @@ -337,11 +328,7 @@ pub fn kevent_ts(kq: RawFd, if let Some(ref timeout) = timeout_opt {timeout as *const timespec} else {ptr::null()}) }; - if res < 0 { - return Err(Error::Sys(Errno::last())); - } - - return Ok(res as usize) + Errno::result(res).map(|r| r as usize) } #[cfg(not(target_os = "netbsd"))] |