Skip to content

Commit 017455c

Browse files
committed
Fix some Clippy lints
New Clippy version, new lints, let's fix them.
1 parent 5b68514 commit 017455c

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

src/sys/unix.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ pub(crate) fn poll_connect(socket: &crate::Socket, timeout: Duration) -> io::Res
631631
}
632632

633633
let timeout = (timeout - elapsed).as_millis();
634-
let timeout = clamp(timeout, 1, c_int::MAX as u128) as c_int;
634+
let timeout = timeout.clamp(1, c_int::MAX as u128) as c_int;
635635

636636
match syscall!(poll(&mut pollfd, 1, timeout)) {
637637
Ok(0) => return Err(io::ErrorKind::TimedOut.into()),
@@ -657,20 +657,6 @@ pub(crate) fn poll_connect(socket: &crate::Socket, timeout: Duration) -> io::Res
657657
}
658658
}
659659

660-
// TODO: use clamp from std lib, stable since 1.50.
661-
fn clamp<T>(value: T, min: T, max: T) -> T
662-
where
663-
T: Ord,
664-
{
665-
if value <= min {
666-
min
667-
} else if value >= max {
668-
max
669-
} else {
670-
value
671-
}
672-
}
673-
674660
pub(crate) fn listen(fd: Socket, backlog: c_int) -> io::Result<()> {
675661
syscall!(listen(fd, backlog)).map(|_| ())
676662
}
@@ -781,6 +767,7 @@ pub(crate) fn recv_from_vectored(
781767

782768
/// Returns the (bytes received, sending address len, `RecvFlags`).
783769
#[cfg(not(target_os = "redox"))]
770+
#[allow(clippy::unnecessary_cast)] // For `IovLen::MAX as usize` (Already `usize` on Linux).
784771
fn recvmsg(
785772
fd: Socket,
786773
msg_name: *mut sockaddr_storage,
@@ -841,6 +828,7 @@ pub(crate) fn send_to_vectored(
841828

842829
/// Returns the (bytes received, sending address len, `RecvFlags`).
843830
#[cfg(not(target_os = "redox"))]
831+
#[allow(clippy::unnecessary_cast)] // For `IovLen::MAX as usize` (Already `usize` on Linux).
844832
fn sendmsg(
845833
fd: Socket,
846834
msg_name: *const sockaddr_storage,

0 commit comments

Comments
 (0)