Skip to content

Commit

Permalink
Replace max_value with MAX constant (#1776)
Browse files Browse the repository at this point in the history
Fixes clippy::legacy_numeric_constants.
  • Loading branch information
Thomasdezeeuw authored Apr 25, 2024
1 parent 15050b9 commit 309daae
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/sys/unix/selector/kqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl Selector {

pub fn select(&self, events: &mut Events, timeout: Option<Duration>) -> io::Result<()> {
let timeout = timeout.map(|to| libc::timespec {
tv_sec: cmp::min(to.as_secs(), libc::time_t::max_value() as u64) as libc::time_t,
tv_sec: cmp::min(to.as_secs(), libc::time_t::MAX as u64) as libc::time_t,
// `Duration::subsec_nanos` is guaranteed to be less than one
// billion (the number of nanoseconds in a second), making the
// cast to i32 safe. The cast itself is needed for platforms
Expand Down
2 changes: 1 addition & 1 deletion src/sys/unix/selector/poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ fn poll(fds: &mut [PollFd], timeout: Option<Duration>) -> io::Result<usize> {
#[cfg(target_pointer_width = "32")]
const MAX_SAFE_TIMEOUT: u128 = 1789569;
#[cfg(not(target_pointer_width = "32"))]
const MAX_SAFE_TIMEOUT: u128 = libc::c_int::max_value() as u128;
const MAX_SAFE_TIMEOUT: u128 = libc::c_int::MAX as u128;

let timeout = timeout
.map(|to| {
Expand Down
2 changes: 1 addition & 1 deletion src/sys/unix/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub(crate) fn connect(socket: &net::TcpStream, addr: SocketAddr) -> io::Result<(
}

pub(crate) fn listen(socket: &net::TcpListener, backlog: u32) -> io::Result<()> {
let backlog = backlog.try_into().unwrap_or(i32::max_value());
let backlog = backlog.try_into().unwrap_or(i32::MAX);
syscall!(listen(socket.as_raw_fd(), backlog))?;
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion src/sys/wasi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl Selector {
}

/// Token used to a add a timeout subscription, also used in removing it again.
const TIMEOUT_TOKEN: wasi::Userdata = wasi::Userdata::max_value();
const TIMEOUT_TOKEN: wasi::Userdata = wasi::Userdata::MAX;

/// Returns a `wasi::Subscription` for `timeout`.
fn timeout_subscription(timeout: Duration) -> wasi::Subscription {
Expand Down
2 changes: 1 addition & 1 deletion src/sys/windows/iocp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl CompletionPort {
);
let mut removed = 0;
let timeout = duration_millis(timeout);
let len = cmp::min(list.len(), <u32>::max_value() as usize) as u32;
let len = cmp::min(list.len(), u32::MAX as usize) as u32;
let ret = unsafe {
GetQueuedCompletionStatusEx(
self.handle.raw(),
Expand Down
2 changes: 1 addition & 1 deletion src/sys/windows/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub(crate) fn listen(socket: &net::TcpListener, backlog: u32) -> io::Result<()>
use std::convert::TryInto;
use WinSock::listen;

let backlog = backlog.try_into().unwrap_or(i32::max_value());
let backlog = backlog.try_into().unwrap_or(i32::MAX);
syscall!(
listen(socket.as_raw_socket() as _, backlog),
PartialEq::eq,
Expand Down

0 comments on commit 309daae

Please sign in to comment.