Skip to content

Commit

Permalink
Miscellaneous clippy fixes. (#868)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfishcode authored Oct 4, 2023
1 parent 760a68e commit f01d1c6
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 16 deletions.
11 changes: 3 additions & 8 deletions src/backend/libc/net/sockopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,8 @@ pub(crate) fn get_socket_reuseport_lb(fd: BorrowedFd<'_>) -> io::Result<bool> {
))]
#[inline]
pub(crate) fn get_socket_protocol(fd: BorrowedFd<'_>) -> io::Result<Option<Protocol>> {
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")]
Expand Down Expand Up @@ -951,7 +946,7 @@ pub(crate) fn get_tcp_cork(fd: BorrowedFd<'_>) -> io::Result<bool> {
#[cfg(linux_kernel)]
#[inline]
pub(crate) fn get_socket_peercred(fd: BorrowedFd<'_>) -> io::Result<UCred> {
getsockopt(fd, c::SOL_SOCKET as _, c::SO_PEERCRED)
getsockopt(fd, c::SOL_SOCKET, c::SO_PEERCRED)
}

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion src/backend/libc/termios/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>`, 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 }
Expand Down
5 changes: 2 additions & 3 deletions src/backend/linux_raw/net/sockopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -797,7 +796,7 @@ pub(crate) fn get_tcp_cork(fd: BorrowedFd<'_>) -> io::Result<bool> {

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

#[inline]
Expand Down
2 changes: 2 additions & 0 deletions src/bitcast.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! The `bitcast` and `bitflags_bits` macros.
#![allow(unused_macros)]

// Ensure that the source and destination types are both primitive integer
Expand Down
6 changes: 3 additions & 3 deletions src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,9 @@ pub unsafe fn sigtimedwait(set: &Sigset, timeout: Option<Timespec>) -> 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.
///
Expand Down
2 changes: 1 addition & 1 deletion src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit f01d1c6

Please sign in to comment.