Skip to content

Commit

Permalink
apparently error number is returned directly on every os
Browse files Browse the repository at this point in the history
  • Loading branch information
ocadaruma committed Sep 26, 2021
1 parent d4c8c79 commit b86ba85
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/fcntl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,6 @@ mod posix_fadvise {
use crate::errno::Errno;
use std::os::unix::io::RawFd;
use crate::Result;
use cfg_if::cfg_if;

libc_enum! {
#[repr(i32)]
Expand All @@ -671,16 +670,10 @@ mod posix_fadvise {
) -> Result<()> {
let res = unsafe { libc::posix_fadvise(fd, offset, len, advice as libc::c_int) };

cfg_if! {
if #[cfg(any(target_os = "linux", target_os = "freebsd"))] {
if res == 0 {
Ok(())
} else {
Err(Errno::from_i32(res))
}
} else {
Errno::result(res).map(drop)
}
if res == 0 {
Ok(())
} else {
Err(Errno::from_i32(res))
}
}
}
Expand Down

0 comments on commit b86ba85

Please sign in to comment.