Skip to content

Commit f0611af

Browse files
committed
Use new helper in eventfd
1 parent 8a58a1c commit f0611af

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/shims/unix/linux/eventfd.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Linux `eventfd` implementation.
22
use std::cell::{Cell, RefCell};
33
use std::io;
4-
use std::io::{Error, ErrorKind};
4+
use std::io::ErrorKind;
55

66
use crate::concurrency::VClock;
77
use crate::shims::unix::fd::FileDescriptionRef;
@@ -66,9 +66,7 @@ impl FileDescription for Event {
6666
let ty = ecx.machine.layouts.u64;
6767
// Check the size of slice, and return error only if the size of the slice < 8.
6868
if len < ty.size.bytes_usize() {
69-
ecx.set_last_error_from_io_error(Error::from(ErrorKind::InvalidInput))?;
70-
ecx.write_int(-1, dest)?;
71-
return Ok(());
69+
return ecx.set_last_error_and_return(ErrorKind::InvalidInput, dest);
7270
}
7371

7472
// eventfd read at the size of u64.
@@ -78,9 +76,7 @@ impl FileDescription for Event {
7876
let counter = self.counter.get();
7977
if counter == 0 {
8078
if self.is_nonblock {
81-
ecx.set_last_error_from_io_error(Error::from(ErrorKind::WouldBlock))?;
82-
ecx.write_int(-1, dest)?;
83-
return Ok(());
79+
return ecx.set_last_error_and_return(ErrorKind::WouldBlock, dest);
8480
}
8581

8682
throw_unsup_format!("eventfd: blocking is unsupported");

0 commit comments

Comments
 (0)