Skip to content

Commit f092873

Browse files
committed
chore: apply some clippy lints
1 parent e70f6ea commit f092873

File tree

15 files changed

+36
-39
lines changed

15 files changed

+36
-39
lines changed

Cargo.toml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,16 @@ members = [
143143
"libc-test",
144144
]
145145

146-
#
147-
# TODO: These should be renamed as `[workspace.lints.*]` once MSRV is abve 1.64
146+
# FIXME(msrv): These should be renamed as `[workspace.lints.*]` once MSRV is above 1.64
148147
# This way all crates can use it with `[lints] workspace=true` section
149-
#
150148

151149
[lints.rust]
152-
# TODO: make ident usage consistent in each file
150+
# FIXME(cleanup): make ident usage consistent in each file
153151
unused_qualifications = "allow"
154152

155153
[lints.clippy]
156-
# TODO: enable pedantic lints with exceptions
157-
non_minimal_cfg = "allow" # for some reason cfg_if! sometimes trigger this
158154
identity_op = "allow" # some expressions like `0 | x` are clearer for bit ops
159155
missing_safety_doc = "allow" # safety? in libc? seriously?
156+
157+
# FIXME(clippy): all these should probably be fixed
158+
non_minimal_cfg = "allow" # for some reason cfg_if! sometimes trigger this

src/fuchsia/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3429,9 +3429,9 @@ f! {
34293429

34303430
pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr {
34313431
if ((*cmsg).cmsg_len as size_t) < mem::size_of::<cmsghdr>() {
3432-
0 as *mut cmsghdr
3432+
core::ptr::null_mut::<cmsghdr>()
34333433
} else if __CMSG_NEXT(cmsg).add(mem::size_of::<cmsghdr>()) >= __MHDR_END(mhdr) {
3434-
0 as *mut cmsghdr
3434+
core::ptr::null_mut::<cmsghdr>()
34353435
} else {
34363436
__CMSG_NEXT(cmsg).cast()
34373437
}
@@ -3441,7 +3441,7 @@ f! {
34413441
if (*mhdr).msg_controllen as size_t >= mem::size_of::<cmsghdr>() {
34423442
(*mhdr).msg_control.cast()
34433443
} else {
3444-
0 as *mut cmsghdr
3444+
core::ptr::null_mut::<cmsghdr>()
34453445
}
34463446
}
34473447

src/unix/aix/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2441,7 +2441,7 @@ f! {
24412441
if (*mhdr).msg_controllen as usize >= mem::size_of::<cmsghdr>() {
24422442
(*mhdr).msg_control as *mut cmsghdr
24432443
} else {
2444-
0 as *mut cmsghdr
2444+
core::ptr::null_mut::<cmsghdr>()
24452445
}
24462446
}
24472447

@@ -2452,7 +2452,7 @@ f! {
24522452
if (cmsg as usize + (*cmsg).cmsg_len as usize + mem::size_of::<cmsghdr>())
24532453
> ((*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize)
24542454
{
2455-
0 as *mut cmsghdr
2455+
core::ptr::null_mut::<cmsghdr>()
24562456
} else {
24572457
// AIX does not have any alignment/padding for ancillary data, so we don't need _CMSG_ALIGN here.
24582458
(cmsg as usize + (*cmsg).cmsg_len as usize) as *mut cmsghdr

src/unix/bsd/freebsdlike/dragonfly/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1560,7 +1560,7 @@ f! {
15601560
if next <= max {
15611561
(cmsg as usize + _CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr
15621562
} else {
1563-
0 as *mut cmsghdr
1563+
core::ptr::null_mut::<cmsghdr>()
15641564
}
15651565
}
15661566

src/unix/bsd/freebsdlike/freebsd/mod.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4921,7 +4921,7 @@ f! {
49214921
cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + _ALIGN(mem::size_of::<cmsghdr>());
49224922
let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize;
49234923
if next > max {
4924-
0 as *mut cmsghdr
4924+
core::ptr::null_mut::<cmsghdr>()
49254925
} else {
49264926
(cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr
49274927
}
@@ -4952,30 +4952,28 @@ f! {
49524952
__xuname(256, buf as *mut c_void)
49534953
}
49544954

4955-
pub fn CPU_ZERO(cpuset: &mut cpuset_t) -> () {
4955+
pub fn CPU_ZERO(cpuset: &mut cpuset_t) {
49564956
for slot in cpuset.__bits.iter_mut() {
49574957
*slot = 0;
49584958
}
49594959
}
49604960

4961-
pub fn CPU_FILL(cpuset: &mut cpuset_t) -> () {
4961+
pub fn CPU_FILL(cpuset: &mut cpuset_t) {
49624962
for slot in cpuset.__bits.iter_mut() {
49634963
*slot = !0;
49644964
}
49654965
}
49664966

4967-
pub fn CPU_SET(cpu: usize, cpuset: &mut cpuset_t) -> () {
4967+
pub fn CPU_SET(cpu: usize, cpuset: &mut cpuset_t) {
49684968
let bitset_bits = 8 * mem::size_of::<c_long>();
49694969
let (idx, offset) = (cpu / bitset_bits, cpu % bitset_bits);
49704970
cpuset.__bits[idx] |= 1 << offset;
4971-
()
49724971
}
49734972

4974-
pub fn CPU_CLR(cpu: usize, cpuset: &mut cpuset_t) -> () {
4973+
pub fn CPU_CLR(cpu: usize, cpuset: &mut cpuset_t) {
49754974
let bitset_bits = 8 * mem::size_of::<c_long>();
49764975
let (idx, offset) = (cpu / bitset_bits, cpu % bitset_bits);
49774976
cpuset.__bits[idx] &= !(1 << offset);
4978-
()
49794977
}
49804978

49814979
pub fn CPU_ISSET(cpu: usize, cpuset: &cpuset_t) -> bool {

src/unix/bsd/netbsdlike/netbsd/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2438,7 +2438,7 @@ f! {
24382438
cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + _ALIGN(mem::size_of::<cmsghdr>());
24392439
let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize;
24402440
if next > max {
2441-
0 as *mut cmsghdr
2441+
core::ptr::null_mut::<cmsghdr>()
24422442
} else {
24432443
(cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr
24442444
}

src/unix/bsd/netbsdlike/openbsd/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1940,7 +1940,7 @@ f! {
19401940
cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + _ALIGN(mem::size_of::<cmsghdr>());
19411941
let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize;
19421942
if next > max {
1943-
0 as *mut cmsghdr
1943+
core::ptr::null_mut::<cmsghdr>()
19441944
} else {
19451945
(cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr
19461946
}

src/unix/haiku/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,7 +1570,7 @@ f! {
15701570
if (*mhdr).msg_controllen as usize >= mem::size_of::<cmsghdr>() {
15711571
(*mhdr).msg_control as *mut cmsghdr
15721572
} else {
1573-
0 as *mut cmsghdr
1573+
core::ptr::null_mut::<cmsghdr>()
15741574
}
15751575
}
15761576

@@ -1595,7 +1595,7 @@ f! {
15951595
+ CMSG_ALIGN(mem::size_of::<cmsghdr>());
15961596
let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize;
15971597
if next > max {
1598-
0 as *mut cmsghdr
1598+
core::ptr::null_mut::<cmsghdr>()
15991599
} else {
16001600
(cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr
16011601
}

src/unix/hurd/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3444,7 +3444,7 @@ f! {
34443444
if (*mhdr).msg_controllen as usize >= mem::size_of::<cmsghdr>() {
34453445
(*mhdr).msg_control as *mut cmsghdr
34463446
} else {
3447-
0 as *mut cmsghdr
3447+
core::ptr::null_mut::<cmsghdr>()
34483448
}
34493449
}
34503450

@@ -3462,14 +3462,14 @@ f! {
34623462

34633463
pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr {
34643464
if ((*cmsg).cmsg_len as usize) < mem::size_of::<cmsghdr>() {
3465-
return 0 as *mut cmsghdr;
3465+
return core::ptr::null_mut::<cmsghdr>();
34663466
};
34673467
let next = (cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr;
34683468
let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize;
34693469
if (next.offset(1)) as usize > max
34703470
|| next as usize + CMSG_ALIGN((*next).cmsg_len as usize) > max
34713471
{
3472-
0 as *mut cmsghdr
3472+
core::ptr::null_mut::<cmsghdr>()
34733473
} else {
34743474
next as *mut cmsghdr
34753475
}

src/unix/linux_like/android/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3611,7 +3611,7 @@ f! {
36113611
let next = (cmsg as usize + super::CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr;
36123612
let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize;
36133613
if (next.offset(1)) as usize > max {
3614-
0 as *mut cmsghdr
3614+
core::ptr::null_mut::<cmsghdr>()
36153615
} else {
36163616
next as *mut cmsghdr
36173617
}

0 commit comments

Comments
 (0)