Skip to content

Commit 2b7815e

Browse files
committed
Remove need for EAI_SYSTEM.
1 parent e191517 commit 2b7815e

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/libstd/sys/unix/net.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr};
99
use crate::sys_common::{AsInner, FromInner, IntoInner};
1010
use crate::time::{Duration, Instant};
1111

12-
use libc::{c_int, c_void, size_t, sockaddr, socklen_t, EAI_SYSTEM, MSG_PEEK};
12+
use libc::{c_int, c_void, size_t, sockaddr, socklen_t, MSG_PEEK};
1313

1414
pub use crate::sys::{cvt, cvt_r};
1515

@@ -81,17 +81,20 @@ pub fn cvt_gai(err: c_int) -> io::Result<()> {
8181
// We may need to trigger a glibc workaround. See on_resolver_failure() for details.
8282
on_resolver_failure();
8383

84-
if err == EAI_SYSTEM {
85-
return Err(io::Error::last_os_error());
86-
}
87-
8884
#[cfg(target_os = "freertos")]
8985
let detail = format!("error code {}", err);
9086

9187
#[cfg(not(target_os = "freertos"))]
92-
let detail = unsafe {
93-
str::from_utf8(CStr::from_ptr(libc::gai_strerror(err)).to_bytes()).unwrap().to_owned()
88+
let detail = {
89+
if err == libc::EAI_SYSTEM {
90+
return Err(io::Error::last_os_error());
91+
}
92+
93+
unsafe {
94+
str::from_utf8(CStr::from_ptr(libc::gai_strerror(err)).to_bytes()).unwrap().to_owned()
95+
}
9496
};
97+
9598
Err(io::Error::new(
9699
io::ErrorKind::Other,
97100
&format!("failed to lookup address information: {}", detail)[..],

0 commit comments

Comments
 (0)