Redefine ErrorKind::Other and stop using it in std.

This commit is contained in:
Mara Bos
2021-05-27 14:03:35 +02:00
parent cdbe288897
commit 0b37bb2bc2
24 changed files with 89 additions and 75 deletions

View File

@@ -358,7 +358,7 @@ impl FileAttr {
}))
} else {
Err(io::Error::new_const(
io::ErrorKind::Other,
io::ErrorKind::Unknown,
&"creation time is not available for the filesystem",
))
};

View File

@@ -155,7 +155,7 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind {
// clause
x if x == libc::EAGAIN || x == libc::EWOULDBLOCK => ErrorKind::WouldBlock,
_ => ErrorKind::Other,
_ => ErrorKind::Unknown,
}
}

View File

@@ -38,7 +38,7 @@ pub fn cvt_gai(err: c_int) -> io::Result<()> {
str::from_utf8(CStr::from_ptr(libc::gai_strerror(err)).to_bytes()).unwrap().to_owned()
};
Err(io::Error::new(
io::ErrorKind::Other,
io::ErrorKind::Unknown,
&format!("failed to lookup address information: {}", detail)[..],
))
}
@@ -178,7 +178,7 @@ impl Socket {
if pollfd.revents & libc::POLLHUP != 0 {
let e = self.take_error()?.unwrap_or_else(|| {
io::Error::new_const(
io::ErrorKind::Other,
io::ErrorKind::Unknown,
&"no error set after POLLHUP",
)
});

View File

@@ -280,7 +280,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
))?;
if path_len <= 1 {
return Err(io::Error::new_const(
io::ErrorKind::Other,
io::ErrorKind::Unknown,
&"KERN_PROC_PATHNAME sysctl returned zero-length string",
));
}
@@ -303,7 +303,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
return crate::fs::read_link(curproc_exe);
}
Err(io::Error::new_const(
io::ErrorKind::Other,
io::ErrorKind::Unknown,
&"/proc/curproc/exe doesn't point to regular file.",
))
}
@@ -321,7 +321,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
cvt(libc::sysctl(mib, 4, argv.as_mut_ptr() as *mut _, &mut argv_len, ptr::null_mut(), 0))?;
argv.set_len(argv_len as usize);
if argv[0].is_null() {
return Err(io::Error::new_const(io::ErrorKind::Other, &"no current exe available"));
return Err(io::Error::new_const(io::ErrorKind::Unknown, &"no current exe available"));
}
let argv0 = CStr::from_ptr(argv[0]).to_bytes();
if argv0[0] == b'.' || argv0.iter().any(|b| *b == b'/') {
@@ -336,7 +336,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
pub fn current_exe() -> io::Result<PathBuf> {
match crate::fs::read_link("/proc/self/exe") {
Err(ref e) if e.kind() == io::ErrorKind::NotFound => Err(io::Error::new_const(
io::ErrorKind::Other,
io::ErrorKind::Unknown,
&"no /proc/self/exe available. Is /proc mounted?",
)),
other => other,
@@ -423,7 +423,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
_get_next_image_info(0, &mut cookie, &mut info, mem::size_of::<image_info>() as i32);
if result != 0 {
use crate::io::ErrorKind;
Err(io::Error::new_const(ErrorKind::Other, &"Error getting executable path"))
Err(io::Error::new_const(ErrorKind::Unknown, &"Error getting executable path"))
} else {
let name = CStr::from_ptr(info.name.as_ptr()).to_bytes();
Ok(PathBuf::from(OsStr::from_bytes(name)))