From dc37959ce858e1c3a872449cf289c9d9fa2efd2e Mon Sep 17 00:00:00 2001 From: Tomoaki Kawada Date: Fri, 1 Sep 2023 11:43:48 +0900 Subject: [PATCH 1/2] kmc-solid: Directly delegate to `net::is_interrupted` in `std::sys::solid::is_interrupted` --- library/std/src/sys/solid/error.rs | 5 ----- library/std/src/sys/solid/mod.rs | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/library/std/src/sys/solid/error.rs b/library/std/src/sys/solid/error.rs index d1877a8bcd2bf..547b4f3a9840e 100644 --- a/library/std/src/sys/solid/error.rs +++ b/library/std/src/sys/solid/error.rs @@ -31,11 +31,6 @@ pub fn error_name(er: abi::ER) -> Option<&'static str> { } } -#[inline] -fn is_interrupted(er: abi::ER) -> bool { - false -} - pub fn decode_error_kind(er: abi::ER) -> ErrorKind { match er { // Success diff --git a/library/std/src/sys/solid/mod.rs b/library/std/src/sys/solid/mod.rs index e7029174511ca..5af83653cf849 100644 --- a/library/std/src/sys/solid/mod.rs +++ b/library/std/src/sys/solid/mod.rs @@ -74,7 +74,7 @@ pub fn unsupported_err() -> crate::io::Error { #[inline] pub fn is_interrupted(code: i32) -> bool { - error::is_interrupted(code) + net::is_interrupted(code) } pub fn decode_error_kind(code: i32) -> crate::io::ErrorKind { From eb627ea3392c37cd94e7696dca683ef596c8b66c Mon Sep 17 00:00:00 2001 From: Tomoaki Kawada Date: Fri, 1 Sep 2023 11:55:48 +0900 Subject: [PATCH 2/2] kmc-solid: Refactor `is_interrupted` to avoid integer overflow --- library/std/src/sys/solid/net.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/std/src/sys/solid/net.rs b/library/std/src/sys/solid/net.rs index bdd64ab02b770..6adced787f3bb 100644 --- a/library/std/src/sys/solid/net.rs +++ b/library/std/src/sys/solid/net.rs @@ -183,8 +183,7 @@ pub(super) fn error_name(er: abi::ER) -> Option<&'static str> { #[inline] pub fn is_interrupted(er: abi::ER) -> bool { - let errno = netc::SOLID_NET_ERR_BASE - er; - errno as libc::c_int == libc::EINTR + er == netc::SOLID_NET_ERR_BASE - libc::EINTR } pub(super) fn decode_error_kind(er: abi::ER) -> ErrorKind {