Skip to content

Commit

Permalink
Fix unused_qualifications
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardosm committed Nov 26, 2024
1 parent 217a2e5 commit 5b7cad0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 34 deletions.
9 changes: 2 additions & 7 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,7 @@ fn rustc_minor_nightly() -> (u32, bool) {
}

fn which_freebsd() -> Option<i32> {
let output = std::process::Command::new("freebsd-version")
.output()
.ok()?;
let output = Command::new("freebsd-version").output().ok()?;
if !output.status.success() {
return None;
}
Expand All @@ -195,10 +193,7 @@ fn which_freebsd() -> Option<i32> {
}

fn emcc_version_code() -> Option<u64> {
let output = std::process::Command::new("emcc")
.arg("-dumpversion")
.output()
.ok()?;
let output = Command::new("emcc").arg("-dumpversion").output().ok()?;
if !output.status.success() {
return None;
}
Expand Down
40 changes: 20 additions & 20 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Linux-specific definitions for linux-like values
use core::mem;
use core::mem::size_of;

pub type useconds_t = u32;
pub type dev_t = u64;
Expand Down Expand Up @@ -3726,15 +3726,15 @@ pub const TP_FT_REQ_FILL_RXHASH: ::__u32 = 1;

pub const TPACKET_ALIGNMENT: usize = 16;

pub const TPACKET_HDRLEN: usize = ((mem::size_of::<::tpacket_hdr>() + TPACKET_ALIGNMENT - 1)
pub const TPACKET_HDRLEN: usize = ((size_of::<::tpacket_hdr>() + TPACKET_ALIGNMENT - 1)
& !(TPACKET_ALIGNMENT - 1))
+ mem::size_of::<::sockaddr_ll>();
pub const TPACKET2_HDRLEN: usize = ((mem::size_of::<::tpacket2_hdr>() + TPACKET_ALIGNMENT - 1)
+ size_of::<::sockaddr_ll>();
pub const TPACKET2_HDRLEN: usize = ((size_of::<::tpacket2_hdr>() + TPACKET_ALIGNMENT - 1)
& !(TPACKET_ALIGNMENT - 1))
+ mem::size_of::<::sockaddr_ll>();
pub const TPACKET3_HDRLEN: usize = ((mem::size_of::<::tpacket3_hdr>() + TPACKET_ALIGNMENT - 1)
+ size_of::<::sockaddr_ll>();
pub const TPACKET3_HDRLEN: usize = ((size_of::<::tpacket3_hdr>() + TPACKET_ALIGNMENT - 1)
& !(TPACKET_ALIGNMENT - 1))
+ mem::size_of::<::sockaddr_ll>();
+ size_of::<::sockaddr_ll>();

// linux/netfilter.h
pub const NF_DROP: ::c_int = 0;
Expand Down Expand Up @@ -4198,11 +4198,11 @@ pub const IW_PMKID_CAND_PREAUTH: ::c_ulong = 0x00000001;
pub const IW_EV_LCP_PK_LEN: usize = 4;

pub const IW_EV_CHAR_PK_LEN: usize = 20; // IW_EV_LCP_PK_LEN + ::IFNAMSIZ;
pub const IW_EV_UINT_PK_LEN: usize = 8; // IW_EV_LCP_PK_LEN + ::mem::size_of::<u32>();
pub const IW_EV_FREQ_PK_LEN: usize = 12; // IW_EV_LCP_PK_LEN + ::mem::size_of::<iw_freq>();
pub const IW_EV_PARAM_PK_LEN: usize = 12; // IW_EV_LCP_PK_LEN + ::mem::size_of::<iw_param>();
pub const IW_EV_ADDR_PK_LEN: usize = 20; // IW_EV_LCP_PK_LEN + ::mem::size_of::<::sockaddr>();
pub const IW_EV_QUAL_PK_LEN: usize = 8; // IW_EV_LCP_PK_LEN + ::mem::size_of::<iw_quality>();
pub const IW_EV_UINT_PK_LEN: usize = 8; // IW_EV_LCP_PK_LEN + size_of::<u32>();
pub const IW_EV_FREQ_PK_LEN: usize = 12; // IW_EV_LCP_PK_LEN + size_of::<iw_freq>();
pub const IW_EV_PARAM_PK_LEN: usize = 12; // IW_EV_LCP_PK_LEN + size_of::<iw_param>();
pub const IW_EV_ADDR_PK_LEN: usize = 20; // IW_EV_LCP_PK_LEN + size_of::<::sockaddr>();
pub const IW_EV_QUAL_PK_LEN: usize = 8; // IW_EV_LCP_PK_LEN + size_of::<iw_quality>();
pub const IW_EV_POINT_PK_LEN: usize = 8; // IW_EV_LCP_PK_LEN + 4;

pub const IPTOS_TOS_MASK: u8 = 0x1E;
Expand Down Expand Up @@ -5282,9 +5282,9 @@ pub const CANXL_MAX_DLEN: usize = 2048;
pub const CANXL_XLF: ::c_int = 0x80;
pub const CANXL_SEC: ::c_int = 0x01;

pub const CAN_MTU: usize = ::mem::size_of::<can_frame>();
pub const CANFD_MTU: usize = ::mem::size_of::<canfd_frame>();
pub const CANXL_MTU: usize = ::mem::size_of::<canxl_frame>();
pub const CAN_MTU: usize = size_of::<can_frame>();
pub const CANFD_MTU: usize = size_of::<canfd_frame>();
pub const CANXL_MTU: usize = size_of::<canxl_frame>();
// FIXME(offset_of): use `core::mem::offset_of!` once that is available
// https://github.com/rust-lang/rfcs/pull/3308
// pub const CANXL_HDR_SIZE: usize = core::mem::offset_of!(canxl_frame, data);
Expand Down Expand Up @@ -5760,17 +5760,17 @@ pub(crate) const fn _IO(ty: u32, nr: u32) -> u32 {

/// Build an ioctl number for an read-only ioctl.
pub(crate) const fn _IOR<T>(ty: u32, nr: u32) -> u32 {
_IOC(_IOC_READ, ty, nr, core::mem::size_of::<T>())
_IOC(_IOC_READ, ty, nr, size_of::<T>())
}

/// Build an ioctl number for an write-only ioctl.
pub(crate) const fn _IOW<T>(ty: u32, nr: u32) -> u32 {
_IOC(_IOC_WRITE, ty, nr, core::mem::size_of::<T>())
_IOC(_IOC_WRITE, ty, nr, size_of::<T>())
}

/// Build an ioctl number for a read-write ioctl.
pub(crate) const fn _IOWR<T>(ty: u32, nr: u32) -> u32 {
_IOC(_IOC_READ | _IOC_WRITE, ty, nr, core::mem::size_of::<T>())
_IOC(_IOC_READ | _IOC_WRITE, ty, nr, size_of::<T>())
}

f! {
Expand All @@ -5779,7 +5779,7 @@ f! {
}

pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr {
if ((*cmsg).cmsg_len as usize) < ::mem::size_of::<cmsghdr>() {
if ((*cmsg).cmsg_len as usize) < size_of::<cmsghdr>() {
return 0 as *mut cmsghdr;
};
let next = (cmsg as usize + super::CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr;
Expand Down Expand Up @@ -5835,7 +5835,7 @@ f! {
}

pub fn CPU_COUNT(cpuset: &cpu_set_t) -> ::c_int {
CPU_COUNT_S(::mem::size_of::<cpu_set_t>(), cpuset)
CPU_COUNT_S(size_of::<cpu_set_t>(), cpuset)
}

pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool {
Expand Down
16 changes: 9 additions & 7 deletions src/unix/solarish/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use core::mem::size_of;

pub type c_char = i8;
pub type c_long = i64;
pub type c_ulong = u64;
Expand Down Expand Up @@ -710,9 +712,9 @@ cfg_if! {
fn data_field_count(&self) -> usize {
match self.si_signo {
::SIGSEGV | ::SIGBUS | ::SIGILL | ::SIGTRAP | ::SIGFPE => {
::mem::size_of::<siginfo_fault>() / ::mem::size_of::<::c_int>()
size_of::<siginfo_fault>() / size_of::<::c_int>()
}
::SIGCLD => ::mem::size_of::<siginfo_sigcld>() / ::mem::size_of::<::c_int>(),
::SIGCLD => size_of::<siginfo_sigcld>() / size_of::<::c_int>(),
::SIGHUP
| ::SIGINT
| ::SIGQUIT
Expand All @@ -725,7 +727,7 @@ cfg_if! {
| ::SIGUSR2
| ::SIGPWR
| ::SIGWINCH
| ::SIGURG => ::mem::size_of::<siginfo_kill>() / ::mem::size_of::<::c_int>(),
| ::SIGURG => size_of::<siginfo_kill>() / size_of::<::c_int>(),
_ => SIGINFO_DATA_SIZE,
}
}
Expand Down Expand Up @@ -2456,7 +2458,7 @@ const _CMSG_HDR_ALIGNMENT: usize = 8;
#[cfg(not(target_arch = "sparc64"))]
const _CMSG_HDR_ALIGNMENT: usize = 4;

const _CMSG_DATA_ALIGNMENT: usize = ::mem::size_of::<::c_int>();
const _CMSG_DATA_ALIGNMENT: usize = size_of::<::c_int>();

const NEWDEV: ::c_int = 1;

Expand All @@ -2483,7 +2485,7 @@ f! {
}

pub fn CMSG_FIRSTHDR(mhdr: *const ::msghdr) -> *mut ::cmsghdr {
if ((*mhdr).msg_controllen as usize) < ::mem::size_of::<::cmsghdr>() {
if ((*mhdr).msg_controllen as usize) < size_of::<::cmsghdr>() {
0 as *mut ::cmsghdr
} else {
(*mhdr).msg_control as *mut ::cmsghdr
Expand All @@ -2495,7 +2497,7 @@ f! {
return ::CMSG_FIRSTHDR(mhdr);
};
let next = _CMSG_HDR_ALIGN(
cmsg as usize + (*cmsg).cmsg_len as usize + ::mem::size_of::<::cmsghdr>(),
cmsg as usize + (*cmsg).cmsg_len as usize + size_of::<::cmsghdr>(),
);
let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize;
if next > max {
Expand All @@ -2506,7 +2508,7 @@ f! {
}

pub {const} fn CMSG_SPACE(length: ::c_uint) -> ::c_uint {
_CMSG_HDR_ALIGN(::mem::size_of::<::cmsghdr>() as usize + length as usize) as ::c_uint
_CMSG_HDR_ALIGN(size_of::<::cmsghdr>() as usize + length as usize) as ::c_uint
}

pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
Expand Down

0 comments on commit 5b7cad0

Please sign in to comment.