From a60703430ee708f3899b411f7756e65ea44c8f2a Mon Sep 17 00:00:00 2001 From: Haruki Okada Date: Thu, 23 Sep 2021 20:31:17 +0900 Subject: Fix return value of posix_fadvise libc::posix_fadvise returns errnos directly rather than in the errno variable. --- src/fcntl.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/fcntl.rs') 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 { + ) -> 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)) + } } } -- cgit v1.2.3