From f01d1c63de41ec8ef33b7857f0db22aeadd87d69 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 4 Oct 2023 10:57:35 -0700 Subject: [PATCH] Miscellaneous clippy fixes. (#868) --- src/backend/libc/net/sockopt.rs | 11 +++-------- src/backend/libc/termios/syscalls.rs | 2 +- src/backend/linux_raw/net/sockopt.rs | 5 ++--- src/bitcast.rs | 2 ++ src/runtime.rs | 6 +++--- src/system.rs | 2 +- 6 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/backend/libc/net/sockopt.rs b/src/backend/libc/net/sockopt.rs index 34d7fda3c..2dc84b908 100644 --- a/src/backend/libc/net/sockopt.rs +++ b/src/backend/libc/net/sockopt.rs @@ -424,13 +424,8 @@ pub(crate) fn get_socket_reuseport_lb(fd: BorrowedFd<'_>) -> io::Result { ))] #[inline] pub(crate) fn get_socket_protocol(fd: BorrowedFd<'_>) -> io::Result> { - getsockopt(fd, c::SOL_SOCKET, c::SO_PROTOCOL).map(|raw| { - if let Some(raw) = RawProtocol::new(raw) { - Some(Protocol::from_raw(raw)) - } else { - None - } - }) + getsockopt(fd, c::SOL_SOCKET, c::SO_PROTOCOL) + .map(|raw| RawProtocol::new(raw).map(Protocol::from_raw)) } #[cfg(target_os = "linux")] @@ -951,7 +946,7 @@ pub(crate) fn get_tcp_cork(fd: BorrowedFd<'_>) -> io::Result { #[cfg(linux_kernel)] #[inline] pub(crate) fn get_socket_peercred(fd: BorrowedFd<'_>) -> io::Result { - getsockopt(fd, c::SOL_SOCKET as _, c::SO_PEERCRED) + getsockopt(fd, c::SOL_SOCKET, c::SO_PEERCRED) } #[inline] diff --git a/src/backend/libc/termios/syscalls.rs b/src/backend/libc/termios/syscalls.rs index 7b7c4918f..e18235604 100644 --- a/src/backend/libc/termios/syscalls.rs +++ b/src/backend/libc/termios/syscalls.rs @@ -375,7 +375,7 @@ pub(crate) fn cfmakeraw(termios: &mut Termios) { pub(crate) fn isatty(fd: BorrowedFd<'_>) -> bool { // Use the return value of `isatty` alone. We don't check `errno` because // we return `bool` rather than `io::Result`, because we assume - // `BorrrowedFd` protects us from `EBADF`, and any other reasonably + // `BorrowedFd` protects us from `EBADF`, and any other reasonably // anticipated `errno` value would end up interpreted as “assume it's not a // terminal” anyway. unsafe { c::isatty(borrowed_fd(fd)) != 0 } diff --git a/src/backend/linux_raw/net/sockopt.rs b/src/backend/linux_raw/net/sockopt.rs index a3238f21f..6a740bbf7 100644 --- a/src/backend/linux_raw/net/sockopt.rs +++ b/src/backend/linux_raw/net/sockopt.rs @@ -12,10 +12,9 @@ use crate::fd::BorrowedFd; use crate::ffi::CStr; use crate::io; use crate::net::sockopt::Timeout; -use crate::net::UCred; use crate::net::{ AddressFamily, Ipv4Addr, Ipv6Addr, Protocol, RawProtocol, SocketAddrAny, SocketAddrStorage, - SocketAddrV4, SocketAddrV6, SocketType, + SocketAddrV4, SocketAddrV6, SocketType, UCred, }; #[cfg(feature = "alloc")] use alloc::borrow::ToOwned; @@ -797,7 +796,7 @@ pub(crate) fn get_tcp_cork(fd: BorrowedFd<'_>) -> io::Result { #[inline] pub(crate) fn get_socket_peercred(fd: BorrowedFd<'_>) -> io::Result { - getsockopt(fd, c::SOL_SOCKET as _, linux_raw_sys::net::SO_PEERCRED) + getsockopt(fd, c::SOL_SOCKET, linux_raw_sys::net::SO_PEERCRED) } #[inline] diff --git a/src/bitcast.rs b/src/bitcast.rs index 735101766..77e0e6338 100644 --- a/src/bitcast.rs +++ b/src/bitcast.rs @@ -1,3 +1,5 @@ +//! The `bitcast` and `bitflags_bits` macros. + #![allow(unused_macros)] // Ensure that the source and destination types are both primitive integer diff --git a/src/runtime.rs b/src/runtime.rs index cb7fc5ea9..745440fc5 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -489,9 +489,9 @@ pub unsafe fn sigtimedwait(set: &Sigset, timeout: Option) -> io::Resul /// `getauxval(AT_SECURE)`—Returns the Linux "secure execution" mode. /// /// Return a boolean value indicating whether "secure execution" mode was -/// requested, due the the process having elevated privileges. This includes -/// whether the `AT_SECURE` AUX value is set, and whether the initial real -/// UID and GID differ from the initial effective UID and GID. +/// requested, due to the process having elevated privileges. This includes +/// whether the `AT_SECURE` AUX value is set, and whether the initial real UID +/// and GID differ from the initial effective UID and GID. /// /// The meaning of "secure execution" mode is beyond the scope of this comment. /// diff --git a/src/system.rs b/src/system.rs index 1ceb5afaa..068d23717 100644 --- a/src/system.rs +++ b/src/system.rs @@ -157,7 +157,7 @@ pub fn sethostname(name: &[u8]) -> io::Result<()> { backend::system::syscalls::sethostname(name) } -/// Reboot command for use use with [`reboot`]. +/// Reboot command for use with [`reboot`]. #[cfg(target_os = "linux")] #[derive(Copy, Clone, Debug, Eq, PartialEq)] #[repr(i32)]