Skip to content

Commit

Permalink
Fix #1
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmarkov committed Jun 3, 2024
1 parent a070ca7 commit 2b3de95
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,25 @@ use libc as sys;
#[macro_export]
macro_rules! syscall {
($ret:expr) => {{
if $ret != 0 {
Err(::std::io::Error::from_raw_os_error($ret))
let result = $ret;

if result != 0 {
Err(::std::io::Error::from_raw_os_error(result))
} else {
Ok($ret)
Ok(result)
}
}};
}

#[macro_export]
macro_rules! syscall_los {
($ret:expr) => {{
if $ret == (u32::MAX as _) {
Err(io::Error::last_os_error())
let result = $ret;

if result == -1 {
Err(::std::io::Error::last_os_error())
} else {
Ok($ret)
Ok(result)
}
}};
}
Expand Down

0 comments on commit 2b3de95

Please sign in to comment.