From b33353cc46b5cb9c4d627e48db0b12e75e3786c6 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Tue, 21 Jun 2022 13:56:12 -0700 Subject: [PATCH] base: remove use of cvt crate cvt isn't used anywhere else in the base crate, and it isn't included in the ChromeOS crosvm ebuild, so this breaks the CrOS build. Just check the result and return an error the same way we do elsewhere in base. BUG=b:231641496 TEST=cargo build TEST=emerge-hatch crosvm Fixes: 21445b1b8378 ("base: Upstream unix net set_nonblocking fn") Change-Id: Iba8beee21810210e50e0c715a1b84de29278625a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3716851 Tested-by: kokoro Reviewed-by: Dennis Kempin Commit-Queue: Daniel Verkamp --- base/Cargo.toml | 3 --- base/src/sys/unix/net.rs | 15 ++++++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/base/Cargo.toml b/base/Cargo.toml index 68926f475c..a09952b387 100644 --- a/base/Cargo.toml +++ b/base/Cargo.toml @@ -27,9 +27,6 @@ tempfile = "3" thiserror = "1.0.20" uuid = { version = "0.8.2", features = ["v4"] } -[target.'cfg(unix)'.dependencies] -cvt = "*" - [target.'cfg(windows)'.dependencies] lazy_static = "*" rand = "*" diff --git a/base/src/sys/unix/net.rs b/base/src/sys/unix/net.rs index c3148f89dc..4c7cddc544 100644 --- a/base/src/sys/unix/net.rs +++ b/base/src/sys/unix/net.rs @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -use cvt::cvt; use std::{ cmp::Ordering, convert::TryFrom, @@ -599,7 +598,12 @@ impl UnixSeqpacket { /// Sets the blocking mode for this socket. pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> { let mut nonblocking = nonblocking as libc::c_int; - cvt(unsafe { libc::ioctl(self.fd, libc::FIONBIO, &mut nonblocking) }).map(drop) + let ret = unsafe { libc::ioctl(self.fd, libc::FIONBIO, &mut nonblocking) }; + if ret < 0 { + Err(io::Error::last_os_error()) + } else { + Ok(()) + } } } @@ -798,7 +802,12 @@ impl UnixSeqpacketListener { /// Sets the blocking mode for this socket. pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> { let mut nonblocking = nonblocking as libc::c_int; - cvt(unsafe { libc::ioctl(self.fd, libc::FIONBIO, &mut nonblocking) }).map(drop) + let ret = unsafe { libc::ioctl(self.fd, libc::FIONBIO, &mut nonblocking) }; + if ret < 0 { + Err(io::Error::last_os_error()) + } else { + Ok(()) + } } }