diff --git a/src/fcntl.rs b/src/fcntl.rs index 8ede0777b3..2000430ccf 100644 --- a/src/fcntl.rs +++ b/src/fcntl.rs @@ -1109,7 +1109,7 @@ mod posix_fadvise { if res == 0 { Ok(()) } else { - Err(Errno::from_i32(res)) + Err(Errno::from_raw(res)) } } } @@ -1131,7 +1131,7 @@ pub fn posix_fallocate( match Errno::result(res) { Err(err) => Err(err), Ok(0) => Ok(()), - Ok(errno) => Err(Errno::from_i32(errno)), + Ok(errno) => Err(Errno::from_raw(errno)), } } } diff --git a/src/sys/aio.rs b/src/sys/aio.rs index e3c44db654..e9213c6434 100644 --- a/src/sys/aio.rs +++ b/src/sys/aio.rs @@ -158,7 +158,7 @@ impl AioCb { let r = unsafe { libc::aio_error(&self.aiocb().0) }; match r { 0 => Ok(()), - num if num > 0 => Err(Errno::from_i32(num)), + num if num > 0 => Err(Errno::from_raw(num)), -1 => Err(Errno::last()), num => panic!("unknown aio_error return value {num:?}"), } diff --git a/src/time.rs b/src/time.rs index 96e84900dd..219f772d46 100644 --- a/src/time.rs +++ b/src/time.rs @@ -196,6 +196,6 @@ pub fn clock_getcpuclockid(pid: Pid) -> Result { let res = unsafe { clk_id.assume_init() }; Ok(ClockId::from(res)) } else { - Err(Errno::from_i32(ret)) + Err(Errno::from_raw(ret)) } } diff --git a/src/unistd.rs b/src/unistd.rs index 92840f7e8b..5653b2942e 100644 --- a/src/unistd.rs +++ b/src/unistd.rs @@ -1,6 +1,6 @@ //! Safe wrappers around functions found in libc "unistd.h" header -use crate::errno::{self, Errno}; +use crate::errno::Errno; #[cfg(any( all(feature = "fs", not(target_os = "redox")), @@ -2146,7 +2146,7 @@ pub fn fpathconf(fd: F, var: PathconfVar) -> Result> { libc::fpathconf(fd.as_fd().as_raw_fd(), var as c_int) }; if raw == -1 { - if errno::errno() == 0 { + if Errno::last_raw() == 0 { Ok(None) } else { Err(Errno::last()) @@ -2186,7 +2186,7 @@ pub fn pathconf( libc::pathconf(cstr.as_ptr(), var as c_int) })?; if raw == -1 { - if errno::errno() == 0 { + if Errno::last_raw() == 0 { Ok(None) } else { Err(Errno::last()) @@ -2785,7 +2785,7 @@ pub fn sysconf(var: SysconfVar) -> Result> { libc::sysconf(var as c_int) }; if raw == -1 { - if errno::errno() == 0 { + if Errno::last_raw() == 0 { Ok(None) } else { Err(Errno::last()) @@ -3541,7 +3541,7 @@ pub fn ttyname(fd: F) -> Result { let ret = unsafe { libc::ttyname_r(fd.as_fd().as_raw_fd(), c_buf, buf.len()) }; if ret != 0 { - return Err(Errno::from_i32(ret)); + return Err(Errno::from_raw(ret)); } CStr::from_bytes_until_nul(&buf[..]) diff --git a/test/test_errno.rs b/test/test_errno.rs index a0c2279369..b9f8d45958 100644 --- a/test/test_errno.rs +++ b/test/test_errno.rs @@ -1,8 +1,8 @@ -use nix::errno::{set_errno, Errno}; +use nix::errno::Errno; #[test] fn errno_set_and_read() { Errno::clear(); - set_errno(Errno::ENFILE); + Errno::set(Errno::ENFILE); assert_eq!(Errno::last(), Errno::ENFILE); } diff --git a/test/test_mount.rs b/test/test_mount.rs index 5cf00408e8..09d80bcc6a 100644 --- a/test/test_mount.rs +++ b/test/test_mount.rs @@ -49,7 +49,7 @@ exit 23"; .mode((Mode::S_IRWXU | Mode::S_IRWXG | Mode::S_IRWXO).bits()) .open(&test_path) .or_else(|e| { - if Errno::from_i32(e.raw_os_error().unwrap()) + if Errno::from_raw(e.raw_os_error().unwrap()) == Errno::EOVERFLOW { // Skip tests on certain Linux kernels which have a bug