Skip to content

Use correct error message casing for io::const_errors #137809

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/std/src/io/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl Error {

pub(crate) const UNKNOWN_THREAD_COUNT: Self = const_error!(
ErrorKind::NotFound,
"The number of hardware threads is not known for the target platform",
"the number of hardware threads is not known for the target platform",
);

pub(crate) const UNSUPPORTED_PLATFORM: Self =
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/os/windows/io/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl OwnedSocket {

#[cfg(target_vendor = "uwp")]
pub(crate) fn set_no_inherit(&self) -> io::Result<()> {
Err(io::const_error!(io::ErrorKind::Unsupported, "Unavailable on UWP"))
Err(io::const_error!(io::ErrorKind::Unsupported, "unavailable on UWP"))
}
}

Expand Down
20 changes: 10 additions & 10 deletions library/std/src/sys/net/connection/xous/tcplistener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ macro_rules! unimpl {
() => {
return Err(io::const_error!(
io::ErrorKind::Unsupported,
"This function is not yet implemented",
"this function is not yet implemented",
));
};
}
Expand Down Expand Up @@ -71,7 +71,7 @@ impl TcpListener {
0,
4096,
) else {
return Err(io::const_error!(io::ErrorKind::InvalidInput, "Invalid response"));
return Err(io::const_error!(io::ErrorKind::InvalidInput, "invalid response"));
};

// The first four bytes should be zero upon success, and will be nonzero
Expand All @@ -80,15 +80,15 @@ impl TcpListener {
if response[0] != 0 || valid == 0 {
let errcode = response[1];
if errcode == NetError::SocketInUse as u8 {
return Err(io::const_error!(io::ErrorKind::ResourceBusy, "Socket in use"));
return Err(io::const_error!(io::ErrorKind::ResourceBusy, "socket in use"));
} else if errcode == NetError::Invalid as u8 {
return Err(io::const_error!(io::ErrorKind::AddrNotAvailable, "Invalid address"));
return Err(io::const_error!(io::ErrorKind::AddrNotAvailable, "invalid address"));
} else if errcode == NetError::LibraryError as u8 {
return Err(io::const_error!(io::ErrorKind::Other, "Library error"));
return Err(io::const_error!(io::ErrorKind::Other, "library error"));
} else {
return Err(io::const_error!(
io::ErrorKind::Other,
"Unable to connect or internal error",
"unable to connect or internal error",
));
}
}
Expand Down Expand Up @@ -131,7 +131,7 @@ impl TcpListener {
} else if receive_request.raw[1] == NetError::WouldBlock as u8 {
return Err(io::const_error!(io::ErrorKind::WouldBlock, "accept would block"));
} else if receive_request.raw[1] == NetError::LibraryError as u8 {
return Err(io::const_error!(io::ErrorKind::Other, "Library error"));
return Err(io::const_error!(io::ErrorKind::Other, "library error"));
} else {
return Err(io::const_error!(io::ErrorKind::Other, "library error"));
}
Expand Down Expand Up @@ -169,7 +169,7 @@ impl TcpListener {
Ok((TcpStream::from_listener(stream_fd, self.local.port(), port, addr), addr))
}
} else {
Err(io::const_error!(io::ErrorKind::InvalidInput, "Unable to accept"))
Err(io::const_error!(io::ErrorKind::InvalidInput, "unable to accept"))
}
}

Expand All @@ -186,7 +186,7 @@ impl TcpListener {
services::net_server(),
services::NetBlockingScalar::StdSetTtlTcp(self.fd.load(Ordering::Relaxed), ttl).into(),
)
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value")))
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value")))
.map(|_| ())
}

Expand All @@ -195,7 +195,7 @@ impl TcpListener {
services::net_server(),
services::NetBlockingScalar::StdGetTtlTcp(self.fd.load(Ordering::Relaxed)).into(),
)
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value")))
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value")))
.map(|res| res[0] as _)?)
}

Expand Down
38 changes: 19 additions & 19 deletions library/std/src/sys/net/connection/xous/tcpstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ macro_rules! unimpl {
() => {
return Err(io::const_error!(
io::ErrorKind::Unsupported,
"This function is not yet implemented",
"this function is not yet implemented",
));
};
}
Expand Down Expand Up @@ -96,7 +96,7 @@ impl TcpStream {
0,
4096,
) else {
return Err(io::const_error!(io::ErrorKind::InvalidInput, "Invalid response"));
return Err(io::const_error!(io::ErrorKind::InvalidInput, "invalid response"));
};

// The first four bytes should be zero upon success, and will be nonzero
Expand All @@ -106,13 +106,13 @@ impl TcpStream {
// errcode is a u8 but stuck in a u16 where the upper byte is invalid. Mask & decode accordingly.
let errcode = response[0];
if errcode == NetError::SocketInUse as u8 {
return Err(io::const_error!(io::ErrorKind::ResourceBusy, "Socket in use"));
return Err(io::const_error!(io::ErrorKind::ResourceBusy, "socket in use"));
} else if errcode == NetError::Unaddressable as u8 {
return Err(io::const_error!(io::ErrorKind::AddrNotAvailable, "Invalid address"));
return Err(io::const_error!(io::ErrorKind::AddrNotAvailable, "invalid address"));
} else {
return Err(io::const_error!(
io::ErrorKind::InvalidInput,
"Unable to connect or internal error",
"unable to connect or internal error",
));
}
}
Expand Down Expand Up @@ -198,7 +198,7 @@ impl TcpStream {
) else {
return Err(io::const_error!(
io::ErrorKind::InvalidInput,
"Library failure: wrong message type or messaging error",
"library failure: wrong message type or messaging error",
));
};

Expand All @@ -212,11 +212,11 @@ impl TcpStream {
if result[0] != 0 {
if result[1] == 8 {
// timed out
return Err(io::const_error!(io::ErrorKind::TimedOut, "Timeout"));
return Err(io::const_error!(io::ErrorKind::TimedOut, "timeout"));
}
if result[1] == 9 {
// would block
return Err(io::const_error!(io::ErrorKind::WouldBlock, "Would block"));
return Err(io::const_error!(io::ErrorKind::WouldBlock, "would block"));
}
}
Err(io::const_error!(io::ErrorKind::Other, "recv_slice failure"))
Expand Down Expand Up @@ -258,20 +258,20 @@ impl TcpStream {
self.write_timeout.load(Ordering::Relaxed) as usize,
buf_len,
)
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Internal error")))?;
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "internal error")))?;

if send_request.raw[0] != 0 {
if send_request.raw[4] == 8 {
// timed out
return Err(io::const_error!(
io::ErrorKind::BrokenPipe,
"Timeout or connection closed",
"timeout or connection closed",
));
} else if send_request.raw[4] == 9 {
// would block
return Err(io::const_error!(io::ErrorKind::WouldBlock, "Would block"));
return Err(io::const_error!(io::ErrorKind::WouldBlock, "would block"));
} else {
return Err(io::const_error!(io::ErrorKind::InvalidInput, "Error when sending"));
return Err(io::const_error!(io::ErrorKind::InvalidInput, "error when sending"));
}
}
Ok(u32::from_le_bytes([
Expand Down Expand Up @@ -304,7 +304,7 @@ impl TcpStream {
0,
0,
) else {
return Err(io::const_error!(io::ErrorKind::InvalidInput, "Internal error"));
return Err(io::const_error!(io::ErrorKind::InvalidInput, "internal error"));
};
let mut i = get_addr.raw.iter();
match *i.next().unwrap() {
Expand All @@ -324,7 +324,7 @@ impl TcpStream {
}
Ok(SocketAddr::V6(SocketAddrV6::new(new_addr.into(), self.local_port, 0, 0)))
}
_ => Err(io::const_error!(io::ErrorKind::InvalidInput, "Internal error")),
_ => Err(io::const_error!(io::ErrorKind::InvalidInput, "tnternal error")),
}
}

Expand All @@ -333,7 +333,7 @@ impl TcpStream {
services::net_server(),
services::NetBlockingScalar::StdTcpStreamShutdown(self.fd, how).into(),
)
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value")))
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value")))
.map(|_| ())
}

Expand All @@ -355,7 +355,7 @@ impl TcpStream {
services::net_server(),
services::NetBlockingScalar::StdSetNodelay(self.fd, enabled).into(),
)
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value")))
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value")))
.map(|_| ())
}

Expand All @@ -364,7 +364,7 @@ impl TcpStream {
services::net_server(),
services::NetBlockingScalar::StdGetNodelay(self.fd).into(),
)
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value")))
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value")))
.map(|res| res[0] != 0)?)
}

Expand All @@ -376,7 +376,7 @@ impl TcpStream {
services::net_server(),
services::NetBlockingScalar::StdSetTtlTcp(self.fd, ttl).into(),
)
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value")))
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value")))
.map(|_| ())
}

Expand All @@ -385,7 +385,7 @@ impl TcpStream {
services::net_server(),
services::NetBlockingScalar::StdGetTtlTcp(self.fd).into(),
)
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value")))
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value")))
.map(|res| res[0] as _)?)
}

Expand Down
34 changes: 17 additions & 17 deletions library/std/src/sys/net/connection/xous/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ macro_rules! unimpl {
() => {
return Err(io::const_error!(
io::ErrorKind::Unsupported,
"This function is not yet implemented",
"this function is not yet implemented",
));
};
}
Expand Down Expand Up @@ -72,18 +72,18 @@ impl UdpSocket {
if response[0] != 0 || valid == 0 {
let errcode = response[1];
if errcode == NetError::SocketInUse as u8 {
return Err(io::const_error!(io::ErrorKind::ResourceBusy, "Socket in use"));
return Err(io::const_error!(io::ErrorKind::ResourceBusy, "socket in use"));
} else if errcode == NetError::Invalid as u8 {
return Err(io::const_error!(
io::ErrorKind::InvalidInput,
"Port can't be 0 or invalid address",
"port can't be 0 or invalid address",
));
} else if errcode == NetError::LibraryError as u8 {
return Err(io::const_error!(io::ErrorKind::Other, "Library error"));
return Err(io::const_error!(io::ErrorKind::Other, "library error"));
} else {
return Err(io::const_error!(
io::ErrorKind::Other,
"Unable to connect or internal error",
"unable to connect or internal error",
));
}
}
Expand All @@ -98,13 +98,13 @@ impl UdpSocket {
nonblocking: Cell::new(false),
});
}
Err(io::const_error!(io::ErrorKind::InvalidInput, "Invalid response"))
Err(io::const_error!(io::ErrorKind::InvalidInput, "invalid response"))
}

pub fn peer_addr(&self) -> io::Result<SocketAddr> {
match self.remote.get() {
Some(dest) => Ok(dest),
None => Err(io::const_error!(io::ErrorKind::NotConnected, "No peer specified")),
None => Err(io::const_error!(io::ErrorKind::NotConnected, "no peer specified")),
}
}

Expand Down Expand Up @@ -145,7 +145,7 @@ impl UdpSocket {
} else if receive_request.raw[1] == NetError::WouldBlock as u8 {
return Err(io::const_error!(io::ErrorKind::WouldBlock, "recv would block"));
} else if receive_request.raw[1] == NetError::LibraryError as u8 {
return Err(io::const_error!(io::ErrorKind::Other, "Library error"));
return Err(io::const_error!(io::ErrorKind::Other, "library error"));
} else {
return Err(io::const_error!(io::ErrorKind::Other, "library error"));
}
Expand Down Expand Up @@ -178,7 +178,7 @@ impl UdpSocket {
Ok((rxlen as usize, addr))
}
} else {
Err(io::const_error!(io::ErrorKind::InvalidInput, "Unable to recv"))
Err(io::const_error!(io::ErrorKind::InvalidInput, "unable to recv"))
}
}

Expand Down Expand Up @@ -281,19 +281,19 @@ impl UdpSocket {
if errcode == NetError::SocketInUse as u8 {
return Err(io::const_error!(
io::ErrorKind::ResourceBusy,
"Socket in use",
"socket in use",
));
} else if errcode == NetError::Invalid as u8 {
return Err(io::const_error!(
io::ErrorKind::InvalidInput,
"Socket not valid",
"socket not valid",
));
} else if errcode == NetError::LibraryError as u8 {
return Err(io::const_error!(io::ErrorKind::Other, "Library error"));
return Err(io::const_error!(io::ErrorKind::Other, "library error"));
} else {
return Err(io::const_error!(
io::ErrorKind::Other,
"Unable to connect",
"unable to connect",
));
}
} else {
Expand All @@ -303,13 +303,13 @@ impl UdpSocket {
}
Err(crate::os::xous::ffi::Error::ServerQueueFull) => {
if now.elapsed() >= write_timeout {
return Err(io::const_error!(io::ErrorKind::WouldBlock, "Write timed out"));
return Err(io::const_error!(io::ErrorKind::WouldBlock, "write timed out"));
} else {
// question: do we want to do something a bit more gentle than immediately retrying?
crate::thread::yield_now();
}
}
_ => return Err(io::const_error!(io::ErrorKind::Other, "Library error")),
_ => return Err(io::const_error!(io::ErrorKind::Other, "library error")),
}
}
}
Expand Down Expand Up @@ -363,7 +363,7 @@ impl UdpSocket {
services::net_server(),
services::NetBlockingScalar::StdSetTtlUdp(self.fd, ttl).into(),
)
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value")))
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value")))
.map(|_| ())
}

Expand All @@ -372,7 +372,7 @@ impl UdpSocket {
services::net_server(),
services::NetBlockingScalar::StdGetTtlUdp(self.fd).into(),
)
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value")))
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value")))
.map(|res| res[0] as _)?)
}

Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/pal/hermit/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Thread {
unsafe {
drop(Box::from_raw(p));
}
Err(io::const_error!(io::ErrorKind::Uncategorized, "Unable to create thread!"))
Err(io::const_error!(io::ErrorKind::Uncategorized, "unable to create thread!"))
} else {
Ok(Thread { tid })
};
Expand Down
Loading
Loading