Skip to content

Commit f01d1c6

Browse files
authored
Miscellaneous clippy fixes. (#868)
1 parent 760a68e commit f01d1c6

6 files changed

Lines changed: 12 additions & 16 deletions

File tree

src/backend/libc/net/sockopt.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -424,13 +424,8 @@ pub(crate) fn get_socket_reuseport_lb(fd: BorrowedFd<'_>) -> io::Result<bool> {
424424
))]
425425
#[inline]
426426
pub(crate) fn get_socket_protocol(fd: BorrowedFd<'_>) -> io::Result<Option<Protocol>> {
427-
getsockopt(fd, c::SOL_SOCKET, c::SO_PROTOCOL).map(|raw| {
428-
if let Some(raw) = RawProtocol::new(raw) {
429-
Some(Protocol::from_raw(raw))
430-
} else {
431-
None
432-
}
433-
})
427+
getsockopt(fd, c::SOL_SOCKET, c::SO_PROTOCOL)
428+
.map(|raw| RawProtocol::new(raw).map(Protocol::from_raw))
434429
}
435430

436431
#[cfg(target_os = "linux")]
@@ -951,7 +946,7 @@ pub(crate) fn get_tcp_cork(fd: BorrowedFd<'_>) -> io::Result<bool> {
951946
#[cfg(linux_kernel)]
952947
#[inline]
953948
pub(crate) fn get_socket_peercred(fd: BorrowedFd<'_>) -> io::Result<UCred> {
954-
getsockopt(fd, c::SOL_SOCKET as _, c::SO_PEERCRED)
949+
getsockopt(fd, c::SOL_SOCKET, c::SO_PEERCRED)
955950
}
956951

957952
#[inline]

src/backend/libc/termios/syscalls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ pub(crate) fn cfmakeraw(termios: &mut Termios) {
375375
pub(crate) fn isatty(fd: BorrowedFd<'_>) -> bool {
376376
// Use the return value of `isatty` alone. We don't check `errno` because
377377
// we return `bool` rather than `io::Result<bool>`, because we assume
378-
// `BorrrowedFd` protects us from `EBADF`, and any other reasonably
378+
// `BorrowedFd` protects us from `EBADF`, and any other reasonably
379379
// anticipated `errno` value would end up interpreted as “assume it's not a
380380
// terminal” anyway.
381381
unsafe { c::isatty(borrowed_fd(fd)) != 0 }

src/backend/linux_raw/net/sockopt.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ use crate::fd::BorrowedFd;
1212
use crate::ffi::CStr;
1313
use crate::io;
1414
use crate::net::sockopt::Timeout;
15-
use crate::net::UCred;
1615
use crate::net::{
1716
AddressFamily, Ipv4Addr, Ipv6Addr, Protocol, RawProtocol, SocketAddrAny, SocketAddrStorage,
18-
SocketAddrV4, SocketAddrV6, SocketType,
17+
SocketAddrV4, SocketAddrV6, SocketType, UCred,
1918
};
2019
#[cfg(feature = "alloc")]
2120
use alloc::borrow::ToOwned;
@@ -797,7 +796,7 @@ pub(crate) fn get_tcp_cork(fd: BorrowedFd<'_>) -> io::Result<bool> {
797796

798797
#[inline]
799798
pub(crate) fn get_socket_peercred(fd: BorrowedFd<'_>) -> io::Result<UCred> {
800-
getsockopt(fd, c::SOL_SOCKET as _, linux_raw_sys::net::SO_PEERCRED)
799+
getsockopt(fd, c::SOL_SOCKET, linux_raw_sys::net::SO_PEERCRED)
801800
}
802801

803802
#[inline]

src/bitcast.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! The `bitcast` and `bitflags_bits` macros.
2+
13
#![allow(unused_macros)]
24

35
// Ensure that the source and destination types are both primitive integer

src/runtime.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -489,9 +489,9 @@ pub unsafe fn sigtimedwait(set: &Sigset, timeout: Option<Timespec>) -> io::Resul
489489
/// `getauxval(AT_SECURE)`—Returns the Linux "secure execution" mode.
490490
///
491491
/// Return a boolean value indicating whether "secure execution" mode was
492-
/// requested, due the the process having elevated privileges. This includes
493-
/// whether the `AT_SECURE` AUX value is set, and whether the initial real
494-
/// UID and GID differ from the initial effective UID and GID.
492+
/// requested, due to the process having elevated privileges. This includes
493+
/// whether the `AT_SECURE` AUX value is set, and whether the initial real UID
494+
/// and GID differ from the initial effective UID and GID.
495495
///
496496
/// The meaning of "secure execution" mode is beyond the scope of this comment.
497497
///

src/system.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ pub fn sethostname(name: &[u8]) -> io::Result<()> {
157157
backend::system::syscalls::sethostname(name)
158158
}
159159

160-
/// Reboot command for use use with [`reboot`].
160+
/// Reboot command for use with [`reboot`].
161161
#[cfg(target_os = "linux")]
162162
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
163163
#[repr(i32)]

0 commit comments

Comments
 (0)