diff options
author | Haruki Okada <ocadaruma@gmail.com> | 2021-09-23 20:31:17 +0900 |
---|---|---|
committer | Alan Somers <asomers@gmail.com> | 2021-09-28 19:17:48 -0600 |
commit | a60703430ee708f3899b411f7756e65ea44c8f2a (patch) | |
tree | 7d74d50dbc87efc0810eb1cdc64d4d49ad35e906 /src/fcntl.rs | |
parent | 759b34adea682c5434ea88cea5d666da816149cc (diff) | |
download | nix-a60703430ee708f3899b411f7756e65ea44c8f2a.zip |
Fix return value of posix_fadvise
libc::posix_fadvise returns errnos directly rather than in the errno
variable.
Diffstat (limited to 'src/fcntl.rs')
-rw-r--r-- | src/fcntl.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/fcntl.rs b/src/fcntl.rs index aded27b4..dd8e59a6 100644 --- a/src/fcntl.rs +++ b/src/fcntl.rs @@ -667,9 +667,14 @@ mod posix_fadvise { offset: libc::off_t, len: libc::off_t, advice: PosixFadviseAdvice, - ) -> Result<libc::c_int> { + ) -> Result<()> { let res = unsafe { libc::posix_fadvise(fd, offset, len, advice as libc::c_int) }; - Errno::result(res) + + if res == 0 { + Ok(()) + } else { + Err(Errno::from_i32(res)) + } } } |