Skip to content

Commit e70f6ea

Browse files
committed
wip
1 parent a2dcaf1 commit e70f6ea

File tree

6 files changed

+27
-40
lines changed

6 files changed

+27
-40
lines changed

Cargo.toml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,7 @@ members = [
153153
unused_qualifications = "allow"
154154

155155
[lints.clippy]
156-
# TODO: all these are default lints and should probably be fixed
157-
identity_op = "allow"
158-
if_same_then_else = "allow"
159-
missing_safety_doc = "allow"
160-
non_minimal_cfg = "allow"
161-
precedence = "allow"
162-
redundant_field_names = "allow"
163-
redundant_static_lifetimes = "allow"
164-
unnecessary_cast = "allow"
165-
unused_unit = "allow"
166-
zero_ptr = "allow"
156+
# TODO: enable pedantic lints with exceptions
157+
non_minimal_cfg = "allow" # for some reason cfg_if! sometimes trigger this
158+
identity_op = "allow" # some expressions like `0 | x` are clearer for bit ops
159+
missing_safety_doc = "allow" # safety? in libc? seriously?

build.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::{env, str};
44
// List of cfgs this build script is allowed to set. The list is needed to support check-cfg, as we
55
// need to know all the possible cfgs that this script will set. If you need to set another cfg
66
// make sure to add it to this list as well.
7-
const ALLOWED_CFGS: &'static [&'static str] = &[
7+
const ALLOWED_CFGS: &[&str] = &[
88
"emscripten_old_stat_abi",
99
"espidf_time32",
1010
"freebsd10",
@@ -24,7 +24,7 @@ const ALLOWED_CFGS: &'static [&'static str] = &[
2424
];
2525

2626
// Extra values to allow for check-cfg.
27-
const CHECK_CFG_EXTRA: &'static [(&'static str, &'static [&'static str])] = &[
27+
const CHECK_CFG_EXTRA: &[(&str, &[&str])] = &[
2828
(
2929
"target_os",
3030
&[
@@ -46,7 +46,6 @@ fn main() {
4646
println!("cargo:rerun-if-changed=build.rs");
4747

4848
let (rustc_minor_ver, _is_nightly) = rustc_minor_nightly();
49-
let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok();
5049
let libc_ci = env::var("LIBC_CI").is_ok();
5150
let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap_or_default();
5251
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
@@ -66,10 +65,8 @@ fn main() {
6665
vers
6766
} else if libc_ci {
6867
which_freebsd().unwrap_or(12)
69-
} else if rustc_dep_of_std {
70-
12
7168
} else {
72-
12
69+
12 // regardless of CARGO_FEATURE_RUSTC_DEP_OF_STD env var
7370
};
7471

7572
match which_freebsd {

src/unix/bsd/apple/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5463,7 +5463,7 @@ pub const VMADDR_PORT_ANY: c_uint = 0xFFFFFFFF;
54635463

54645464
const fn __DARWIN_ALIGN32(p: usize) -> usize {
54655465
const __DARWIN_ALIGNBYTES32: usize = mem::size_of::<u32>() - 1;
5466-
p + __DARWIN_ALIGNBYTES32 & !__DARWIN_ALIGNBYTES32
5466+
(p + __DARWIN_ALIGNBYTES32) & !__DARWIN_ALIGNBYTES32
54675467
}
54685468

54695469
pub const THREAD_EXTENDED_POLICY_COUNT: mach_msg_type_number_t =

src/unix/linux_like/linux/gnu/b64/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ cfg_if! {
119119
} else if #[cfg(any(target_arch = "s390x"))] {
120120
mod s390x;
121121
pub use self::s390x::*;
122-
} else if #[cfg(any(target_arch = "x86_64"))] {
122+
} else if #[cfg(target_arch = "x86_64")] {
123123
mod x86_64;
124124
pub use self::x86_64::*;
125125
} else if #[cfg(any(target_arch = "riscv64"))] {

src/unix/linux_like/linux/mod.rs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5975,17 +5975,17 @@ f! {
59755975
}
59765976

59775977
pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr {
5978-
if ((*cmsg).cmsg_len as usize) < size_of::<cmsghdr>() {
5979-
return 0 as *mut cmsghdr;
5978+
if (*cmsg).cmsg_len < size_of::<cmsghdr>() {
5979+
return core::ptr::null_mut::<cmsghdr>();
59805980
};
5981-
let next = (cmsg as usize + super::CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr;
5982-
let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize;
5981+
let next = (cmsg as usize + super::CMSG_ALIGN((*cmsg).cmsg_len)) as *mut cmsghdr;
5982+
let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen;
59835983
if (next.wrapping_offset(1)) as usize > max
59845984
|| next as usize + super::CMSG_ALIGN((*next).cmsg_len as usize) > max
59855985
{
5986-
0 as *mut cmsghdr
5986+
core::ptr::null_mut::<cmsghdr>()
59875987
} else {
5988-
next as *mut cmsghdr
5988+
next
59895989
}
59905990
}
59915991

@@ -6005,14 +6005,12 @@ f! {
60056005
let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
60066006
let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
60076007
cpuset.bits[idx] |= 1 << offset;
6008-
()
60096008
}
60106009

60116010
pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () {
60126011
let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
60136012
let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
60146013
cpuset.bits[idx] &= !(1 << offset);
6015-
()
60166014
}
60176015

60186016
pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool {
@@ -6039,7 +6037,7 @@ f! {
60396037
}
60406038

60416039
pub fn SCTP_PR_INDEX(policy: c_int) -> c_int {
6042-
policy >> 4 - 1
6040+
policy >> (4 - 1)
60436041
}
60446042

60456043
pub fn SCTP_PR_POLICY(policy: c_int) -> c_int {
@@ -6049,7 +6047,6 @@ f! {
60496047
pub fn SCTP_PR_SET_POLICY(flags: &mut c_int, policy: c_int) -> () {
60506048
*flags &= !SCTP_PR_SCTP_MASK;
60516049
*flags |= policy;
6052-
()
60536050
}
60546051

60556052
pub fn IPTOS_TOS(tos: u8) -> u8 {
@@ -6110,19 +6107,19 @@ f! {
61106107

61116108
pub fn BPF_STMT(code: __u16, k: __u32) -> sock_filter {
61126109
sock_filter {
6113-
code: code,
6110+
code,
61146111
jt: 0,
61156112
jf: 0,
6116-
k: k,
6113+
k,
61176114
}
61186115
}
61196116

61206117
pub fn BPF_JUMP(code: __u16, k: __u32, jt: __u8, jf: __u8) -> sock_filter {
61216118
sock_filter {
6122-
code: code,
6123-
jt: jt,
6124-
jf: jf,
6125-
k: k,
6119+
code,
6120+
jt,
6121+
jf,
6122+
k,
61266123
}
61276124
}
61286125

@@ -6135,7 +6132,7 @@ f! {
61356132
}
61366133

61376134
pub fn ELF32_R_INFO(sym: Elf32_Word, t: Elf32_Word) -> Elf32_Word {
6138-
sym << 8 + t & 0xff
6135+
sym << (8 + t) & 0xff
61396136
}
61406137

61416138
pub fn ELF64_R_SYM(val: Elf64_Xword) -> Elf64_Xword {
@@ -6147,7 +6144,7 @@ f! {
61476144
}
61486145

61496146
pub fn ELF64_R_INFO(sym: Elf64_Xword, t: Elf64_Xword) -> Elf64_Xword {
6150-
sym << 32 + t
6147+
sym << (32 + t)
61516148
}
61526149
}
61536150

src/unix/linux_like/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,16 +1699,16 @@ cfg_if! {
16991699

17001700
const_fn! {
17011701
{const} fn CMSG_ALIGN(len: usize) -> usize {
1702-
len + mem::size_of::<usize>() - 1 & !(mem::size_of::<usize>() - 1)
1702+
(len + mem::size_of::<usize>() - 1) & !(mem::size_of::<usize>() - 1)
17031703
}
17041704
}
17051705

17061706
f! {
17071707
pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr {
1708-
if (*mhdr).msg_controllen as usize >= mem::size_of::<cmsghdr>() {
1708+
if (*mhdr).msg_controllen >= mem::size_of::<cmsghdr>() {
17091709
(*mhdr).msg_control as *mut cmsghdr
17101710
} else {
1711-
0 as *mut cmsghdr
1711+
core::ptr::null_mut::<cmsghdr>()
17121712
}
17131713
}
17141714

0 commit comments

Comments
 (0)