diff --git a/examples/tcp_listenfd_server.rs b/examples/tcp_listenfd_server.rs index 941d7f048..38b10d0ef 100644 --- a/examples/tcp_listenfd_server.rs +++ b/examples/tcp_listenfd_server.rs @@ -125,6 +125,7 @@ fn next(current: &mut Token) -> Token { } /// Returns `true` if the connection is done. +#[allow(clippy::unused_io_amount)] fn handle_connection_event( registry: &Registry, connection: &mut TcpStream, diff --git a/examples/tcp_server.rs b/examples/tcp_server.rs index 21e2f2a82..b7d1ab410 100644 --- a/examples/tcp_server.rs +++ b/examples/tcp_server.rs @@ -105,6 +105,7 @@ fn next(current: &mut Token) -> Token { } /// Returns `true` if the connection is done. +#[allow(clippy::unused_io_amount)] fn handle_connection_event( registry: &Registry, connection: &mut TcpStream, diff --git a/src/sys/unix/selector/epoll.rs b/src/sys/unix/selector/epoll.rs index c0a8a4c16..97bb050cc 100644 --- a/src/sys/unix/selector/epoll.rs +++ b/src/sys/unix/selector/epoll.rs @@ -5,7 +5,7 @@ use std::os::unix::io::{AsRawFd, RawFd}; #[cfg(debug_assertions)] use std::sync::atomic::{AtomicUsize, Ordering}; use std::time::Duration; -use std::{cmp, i32, io, ptr}; +use std::{cmp, io, ptr}; /// Unique id for use as `SelectorId`. #[cfg(debug_assertions)] @@ -77,7 +77,7 @@ impl Selector { #[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| { diff --git a/src/sys/unix/selector/kqueue.rs b/src/sys/unix/selector/kqueue.rs index 0a2a24a57..8e5e41025 100644 --- a/src/sys/unix/selector/kqueue.rs +++ b/src/sys/unix/selector/kqueue.rs @@ -92,7 +92,7 @@ impl Selector { pub fn select(&self, events: &mut Events, timeout: Option) -> 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 diff --git a/src/sys/unix/selector/poll.rs b/src/sys/unix/selector/poll.rs index cfafbc182..c8b0c6d20 100644 --- a/src/sys/unix/selector/poll.rs +++ b/src/sys/unix/selector/poll.rs @@ -504,7 +504,7 @@ fn poll(fds: &mut [PollFd], timeout: Option) -> io::Result { #[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| { diff --git a/src/sys/unix/tcp.rs b/src/sys/unix/tcp.rs index 6f755e870..1e3aac352 100644 --- a/src/sys/unix/tcp.rs +++ b/src/sys/unix/tcp.rs @@ -34,7 +34,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(()) } diff --git a/src/sys/unix/waker.rs b/src/sys/unix/waker.rs index 968f1a876..4642996fa 100644 --- a/src/sys/unix/waker.rs +++ b/src/sys/unix/waker.rs @@ -100,6 +100,7 @@ mod eventfd { Ok(WakerInternal { fd: file }) } + #[allow(clippy::unused_io_amount)] pub fn wake(&self) -> io::Result<()> { let buf: [u8; 8] = 1u64.to_ne_bytes(); match (&self.fd).write(&buf) { @@ -120,6 +121,7 @@ mod eventfd { } /// Reset the eventfd object, only need to call this if `wake` fails. + #[allow(clippy::unused_io_amount)] fn reset(&self) -> io::Result<()> { let mut buf: [u8; 8] = 0u64.to_ne_bytes(); match (&self.fd).read(&mut buf) { diff --git a/src/sys/wasi/mod.rs b/src/sys/wasi/mod.rs index b1a25fc9d..596d365d9 100644 --- a/src/sys/wasi/mod.rs +++ b/src/sys/wasi/mod.rs @@ -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 { diff --git a/src/sys/windows/iocp.rs b/src/sys/windows/iocp.rs index c71b695d4..0590bb43f 100644 --- a/src/sys/windows/iocp.rs +++ b/src/sys/windows/iocp.rs @@ -96,7 +96,7 @@ impl CompletionPort { ); let mut removed = 0; let timeout = duration_millis(timeout); - let len = cmp::min(list.len(), ::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(), diff --git a/src/sys/windows/tcp.rs b/src/sys/windows/tcp.rs index addd1e8d8..4f77d5d6e 100644 --- a/src/sys/windows/tcp.rs +++ b/src/sys/windows/tcp.rs @@ -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, diff --git a/tests/close_on_drop.rs b/tests/close_on_drop.rs index 058761a89..7a5fc26f1 100644 --- a/tests/close_on_drop.rs +++ b/tests/close_on_drop.rs @@ -38,6 +38,7 @@ impl TestHandler { } } + #[allow(clippy::unused_io_amount)] fn handle_read(&mut self, registry: &Registry, tok: Token) { debug!("readable; tok={:?}", tok); diff --git a/tests/tcp.rs b/tests/tcp.rs index 2c61403d5..87ef2329d 100644 --- a/tests/tcp.rs +++ b/tests/tcp.rs @@ -584,6 +584,7 @@ fn connect_error() { } #[test] +#[allow(clippy::unused_io_amount)] fn write_error() { init();