Skip to content

Commit

Permalink
Fix miscellaneous clippy lints.
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfishcode committed Oct 24, 2023
1 parent e2314b7 commit 9aa9534
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 42 deletions.
52 changes: 26 additions & 26 deletions src/backend/libc/mount/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ bitflags! {
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct FsOpenFlags: c::c_uint {
/// `FSOPEN_CLOEXEC`
const FSOPEN_CLOEXEC = 0x00000001;
const FSOPEN_CLOEXEC = 0x0000_0001;

/// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
const _ = !0;
Expand All @@ -109,7 +109,7 @@ bitflags! {
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct FsMountFlags: c::c_uint {
/// `FSMOUNT_CLOEXEC`
const FSMOUNT_CLOEXEC = 0x00000001;
const FSMOUNT_CLOEXEC = 0x0000_0001;

/// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
const _ = !0;
Expand Down Expand Up @@ -157,37 +157,37 @@ bitflags! {
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct MountAttrFlags: c::c_uint {
/// `MOUNT_ATTR_RDONLY`
const MOUNT_ATTR_RDONLY = 0x00000001;
const MOUNT_ATTR_RDONLY = 0x0000_0001;

/// `MOUNT_ATTR_NOSUID`
const MOUNT_ATTR_NOSUID = 0x00000002;
const MOUNT_ATTR_NOSUID = 0x0000_0002;

/// `MOUNT_ATTR_NODEV`
const MOUNT_ATTR_NODEV = 0x00000004;
const MOUNT_ATTR_NODEV = 0x0000_0004;

/// `MOUNT_ATTR_NOEXEC`
const MOUNT_ATTR_NOEXEC = 0x00000008;
const MOUNT_ATTR_NOEXEC = 0x0000_0008;

/// `MOUNT_ATTR__ATIME`
const MOUNT_ATTR__ATIME = 0x00000070;
const MOUNT_ATTR__ATIME = 0x0000_0070;

/// `MOUNT_ATTR_RELATIME`
const MOUNT_ATTR_RELATIME = 0x00000000;
const MOUNT_ATTR_RELATIME = 0x0000_0000;

/// `MOUNT_ATTR_NOATIME`
const MOUNT_ATTR_NOATIME = 0x00000010;
const MOUNT_ATTR_NOATIME = 0x0000_0010;

/// `MOUNT_ATTR_STRICTATIME`
const MOUNT_ATTR_STRICTATIME = 0x00000020;
const MOUNT_ATTR_STRICTATIME = 0x0000_0020;

/// `MOUNT_ATTR_NODIRATIME`
const MOUNT_ATTR_NODIRATIME = 0x00000080;
const MOUNT_ATTR_NODIRATIME = 0x0000_0080;

/// `MOUNT_ATTR_NOUSER`
const MOUNT_ATTR_IDMAP = 0x00100000;
const MOUNT_ATTR_IDMAP = 0x0010_0000;

/// `MOUNT_ATTR__ATIME_FLAGS`
const MOUNT_ATTR_NOSYMFOLLOW = 0x00200000;
const MOUNT_ATTR_NOSYMFOLLOW = 0x0020_0000;

/// `MOUNT_ATTR__ATIME_FLAGS`
const MOUNT_ATTR_SIZE_VER0 = 32;
Expand All @@ -207,32 +207,32 @@ bitflags! {
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct MoveMountFlags: c::c_uint {
/// `MOVE_MOUNT_F_EMPTY_PATH`
const MOVE_MOUNT_F_SYMLINKS = 0x00000001;
const MOVE_MOUNT_F_SYMLINKS = 0x0000_0001;

/// `MOVE_MOUNT_F_AUTOMOUNTS`
const MOVE_MOUNT_F_AUTOMOUNTS = 0x00000002;
const MOVE_MOUNT_F_AUTOMOUNTS = 0x0000_0002;

/// `MOVE_MOUNT_F_EMPTY_PATH`
const MOVE_MOUNT_F_EMPTY_PATH = 0x00000004;
const MOVE_MOUNT_F_EMPTY_PATH = 0x0000_0004;

/// `MOVE_MOUNT_T_SYMLINKS`
const MOVE_MOUNT_T_SYMLINKS = 0x00000010;
const MOVE_MOUNT_T_SYMLINKS = 0x0000_0010;

/// `MOVE_MOUNT_T_AUTOMOUNTS`
const MOVE_MOUNT_T_AUTOMOUNTS = 0x00000020;
const MOVE_MOUNT_T_AUTOMOUNTS = 0x0000_0020;

/// `MOVE_MOUNT_T_EMPTY_PATH`
const MOVE_MOUNT_T_EMPTY_PATH = 0x00000040;
const MOVE_MOUNT_T_EMPTY_PATH = 0x0000_0040;

/// `MOVE_MOUNT__MASK`
const MOVE_MOUNT_SET_GROUP = 0x00000100;
const MOVE_MOUNT_SET_GROUP = 0x0000_0100;

// TODO: add when linux 6.5 is released
// /// `MOVE_MOUNT_BENEATH`
// const MOVE_MOUNT_BENEATH = 0x00000200;
// const MOVE_MOUNT_BENEATH = 0x0000_0200;

/// `MOVE_MOUNT__MASK`
const MOVE_MOUNT__MASK = 0x00000377;
const MOVE_MOUNT__MASK = 0x0000_0377;

/// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
const _ = !0;
Expand Down Expand Up @@ -281,16 +281,16 @@ bitflags! {
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct FsPickFlags: c::c_uint {
/// `FSPICK_CLOEXEC`
const FSPICK_CLOEXEC = 0x00000001;
const FSPICK_CLOEXEC = 0x0000_0001;

/// `FSPICK_SYMLINK_NOFOLLOW`
const FSPICK_SYMLINK_NOFOLLOW = 0x00000002;
const FSPICK_SYMLINK_NOFOLLOW = 0x0000_0002;

/// `FSPICK_NO_AUTOMOUNT`
const FSPICK_NO_AUTOMOUNT = 0x00000004;
const FSPICK_NO_AUTOMOUNT = 0x0000_0004;

/// `FSPICK_EMPTY_PATH`
const FSPICK_EMPTY_PATH = 0x00000008;
const FSPICK_EMPTY_PATH = 0x0000_0008;

/// <https://docs.rs/bitflags/latest/bitflags/#externally-defined-flags>
const _ = !0;
Expand Down
4 changes: 2 additions & 2 deletions src/backend/libc/termios/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ pub(crate) fn tcsetattr(
// linux-raw-sys' ioctl-generation script for sparc isn't working yet,
// so as a temporary workaround, declare these manually.
#[cfg(any(target_arch = "sparc", target_arch = "sparc64"))]
const TCSETS: u32 = 0x80245409;
const TCSETS: u32 = 0x8024_5409;
#[cfg(any(target_arch = "sparc", target_arch = "sparc64"))]
const TCSETS2: u32 = 0x802c540d;
const TCSETS2: u32 = 0x802c_540d;

// Translate from `optional_actions` into an ioctl request code. On
// MIPS, `optional_actions` already has `TCGETS` added to it.
Expand Down
2 changes: 1 addition & 1 deletion src/backend/linux_raw/param/auxv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ static ENTRY: AtomicUsize = AtomicUsize::new(0);
#[cfg(feature = "alloc")]
fn pr_get_auxv() -> crate::io::Result<Vec<u8>> {
use super::super::conv::{c_int, pass_usize, ret_usize};
const PR_GET_AUXV: c::c_int = 0x41555856;
const PR_GET_AUXV: c::c_int = 0x4155_5856;
let mut buffer = alloc::vec![0u8; 512];
let len = unsafe {
ret_usize(syscall_always_asm!(
Expand Down
3 changes: 2 additions & 1 deletion src/ioctl/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::backend::c;
use crate::io::Result;

use core::marker::PhantomData;
use core::ptr::addr_of_mut;
use core::{fmt, mem};

/// Implements an `ioctl` with no real arguments.
Expand Down Expand Up @@ -144,7 +145,7 @@ unsafe impl<Opcode: CompileTimeOpcode, Input> Ioctl for Setter<Opcode, Input> {
const OPCODE: self::Opcode = Opcode::OPCODE;

fn as_ptr(&mut self) -> *mut c::c_void {
&mut self.input as *mut Input as *mut c::c_void
addr_of_mut!(self.input).cast::<c::c_void>()
}

unsafe fn output_from_ptr(_: IoctlOutput, _: *mut c::c_void) -> Result<Self::Output> {
Expand Down
15 changes: 4 additions & 11 deletions src/net/send_recv/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use crate::net::UCred;
use core::iter::FusedIterator;
use core::marker::PhantomData;
use core::mem::{align_of, size_of, size_of_val, take};
#[cfg(linux_kernel)]
use core::ptr::addr_of;
use core::{ptr, slice};

use super::{RecvFlags, SendFlags, SocketAddrAny, SocketAddrV4, SocketAddrV6};
Expand Down Expand Up @@ -165,7 +167,7 @@ impl<'buf, 'slice, 'fd> SendAncillaryBuffer<'buf, 'slice, 'fd> {
#[cfg(linux_kernel)]
SendAncillaryMessage::ScmCredentials(ucred) => {
let ucred_bytes = unsafe {
slice::from_raw_parts(&ucred as *const _ as *const u8, size_of_val(&ucred))
slice::from_raw_parts(addr_of!(ucred).cast::<u8>(), size_of_val(&ucred))
};
self.push_ancillary(ucred_bytes, c::SOL_SOCKET as _, c::SCM_CREDENTIALS as _)
}
Expand Down Expand Up @@ -223,6 +225,7 @@ impl<'slice, 'fd> Extend<SendAncillaryMessage<'slice, 'fd>>
}

/// Buffer for receiving ancillary messages with [`recvmsg`].
#[derive(Default)]
pub struct RecvAncillaryBuffer<'buf> {
/// Raw byte buffer for messages.
buffer: &'buf mut [u8],
Expand All @@ -240,16 +243,6 @@ impl<'buf> From<&'buf mut [u8]> for RecvAncillaryBuffer<'buf> {
}
}

impl Default for RecvAncillaryBuffer<'_> {
fn default() -> Self {
Self {
buffer: &mut [],
read: 0,
length: 0,
}
}
}

impl<'buf> RecvAncillaryBuffer<'buf> {
/// Create a new, empty `RecvAncillaryBuffer` from a raw byte buffer.
#[inline]
Expand Down
2 changes: 1 addition & 1 deletion tests/process/prctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ fn test_floating_point_emulation_control() {

#[cfg(feature = "thread")]
pub(crate) fn thread_has_capability(capability: Capability) -> io::Result<bool> {
const _LINUX_CAPABILITY_VERSION_3: u32 = 0x20080522;
const _LINUX_CAPABILITY_VERSION_3: u32 = 0x2008_0522;

#[repr(C)]
struct cap_user_header_t {
Expand Down

0 comments on commit 9aa9534

Please sign in to comment.