From 30616ad26f9462d421db268147627ee9f56f6634 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 15 Jul 2021 18:52:30 +0100 Subject: [PATCH] cargo: upgrade "nix" and get rid of old error klunk Signed-off-by: Ian Jackson --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- apitest/apitest.rs | 7 +++---- src/timedfd.rs | 23 ++++------------------- 4 files changed, 11 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6f8ec54e..0c06ad98 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2152,9 +2152,9 @@ dependencies = [ [[package]] name = "nix" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c3728fec49d363a50a8828a190b379a446cc5cf085c06259bbbeb34447e4ec7" +checksum = "cf1e25ee6b412c2a1e3fcb6a4499a5c1bfe7f43e014bdce9a6b6666e5aa2d187" dependencies = [ "bitflags", "cc", @@ -2422,7 +2422,7 @@ dependencies = [ "libc", "log 0.4.14", "mio 0.7.13", - "nix 0.21.0", + "nix 0.22.0", "num", "num-derive", "num-traits", diff --git a/Cargo.toml b/Cargo.toml index 344af613..c47ae05b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,7 +54,7 @@ lazy-init="0.5" lazy_static="1" libc="0.2" log="0.4" -nix="0.21" +nix="0.22" num="0.4" num-derive="0.3" num-traits="0.2" diff --git a/apitest/apitest.rs b/apitest/apitest.rs index 39d3ea2e..ad060f17 100644 --- a/apitest/apitest.rs +++ b/apitest/apitest.rs @@ -328,10 +328,9 @@ pub mod cleanup_notify { use anyhow::Context; use fehler::{throw, throws}; use libc::_exit; - use nix::errno::Errno::*; use nix::{unistd::*, fcntl::OFlag}; use nix::sys::signal::*; - use nix::Error::Sys; + use nix::Error as NE; use void::Void; use std::io; use std::os::unix::io::RawFd; @@ -353,7 +352,7 @@ pub mod cleanup_notify { match nix::unistd::read(fd, &mut buf) { Ok(0) => break, Ok(_) => throw!(io::Error::from_raw_os_error(libc::EINVAL)), - Err(Sys(EINTR)) => continue, + Err(NE::EINTR) => continue, _ => throw!(io::Error::last_os_error()), } } @@ -398,7 +397,7 @@ pub mod cleanup_notify { for fd in 2.. { if fd == notify_writing_end { continue } let r = close(fd); - if fd > writing_end && matches!(r, Err(Sys(EBADF))) { + if fd > writing_end && matches!(r, Err(NE::EBADF)) { break; } } diff --git a/src/timedfd.rs b/src/timedfd.rs index 641b1fba..1c694f16 100644 --- a/src/timedfd.rs +++ b/src/timedfd.rs @@ -11,11 +11,8 @@ pub trait Timed { pub trait TimedRead : Timed + Read { } pub trait TimedWrite: Timed + Write { } -use io::ErrorKind as EK; - use nix::fcntl::{fcntl, OFlag, FcntlArg}; use nix::Error as NE; -use nix::errno::Errno; use mio::Token; @@ -55,18 +52,6 @@ impl AsRawFd for Fd { fn as_raw_fd(&self) -> RawFd { self.0 } } -#[ext(pub)] -impl nix::Error { - fn as_ioe(self) -> io::Error { - match self { - NE::Sys(e) => return io::Error::from_raw_os_error(e as i32), - NE::UnsupportedOperation => EK::Unsupported, - NE::InvalidPath => EK::InvalidData, - NE::InvalidUtf8 => EK::InvalidData, - }.into() - } -} - impl TimedFd where RW: TimedFdReadWrite { /// Takes ownership of the fd /// @@ -82,7 +67,7 @@ impl TimedFd where RW: TimedFdReadWrite { #[throws(io::Error)] fn from_fd(fd: Fd) -> Self { fcntl(fd.as_raw_fd(), FcntlArg::F_SETFL(OFlag::O_NONBLOCK)) - .map_err(|e| e.as_ioe())?; + .map_err(|e| io::Error::from(e))?; let poll = mio::Poll::new()?; poll.registry().register( @@ -116,9 +101,9 @@ impl TimedFd where RW: TimedFdReadWrite { if event.token() == Token(0) { match f(self.fd.as_raw_fd()) { Ok(got) => { break 'again got }, - Err(NE::Sys(Errno::EINTR)) => continue 'again, - Err(NE::Sys(Errno::EAGAIN)) => break, - Err(ne) => throw!(ne.as_ioe()), + Err(NE::EINTR) => continue 'again, + Err(NE::EAGAIN) => break, + Err(ne) => throw!(ne), } } } -- 2.30.2