Skip to content

Commit 09cef32

Browse files
committed
lints: Remove allow(dead_code)
As discussed in [1], some changes to dead code warnings caused a lot of code to be inaccurately reported as dead in `libc`. The change was reverted and improved since then, so we no longer need to skip this check. Includes some changes to make things pass with the lint. [1]: #3740 (backport <#4473>) (cherry picked from commit 77a21a8)
1 parent 4570ecc commit 09cef32

File tree

8 files changed

+49
-52
lines changed

8 files changed

+49
-52
lines changed

src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
improper_ctypes,
1010
unused_macros,
1111
unused_macro_rules,
12-
// FIXME(1.0): temporarily allow dead_code to fix CI:
13-
// - https://github.com/rust-lang/libc/issues/3740
14-
// - https://github.com/rust-lang/rust/pull/126456
15-
dead_code,
1612
)]
1713
#![cfg_attr(libc_deny_warnings, deny(warnings))]
1814
// Attributes needed when building as part of the standard library

src/unix/linux_like/linux/arch/generic/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ pub const SO_PASSCRED: c_int = 16;
4040
pub const SO_PEERCRED: c_int = 17;
4141
pub const SO_RCVLOWAT: c_int = 18;
4242
pub const SO_SNDLOWAT: c_int = 19;
43-
const SO_RCVTIMEO_OLD: c_int = 20;
44-
const SO_SNDTIMEO_OLD: c_int = 21;
4543
pub const SO_SECURITY_AUTHENTICATION: c_int = 22;
4644
pub const SO_SECURITY_ENCRYPTION_TRANSPORT: c_int = 23;
4745
pub const SO_SECURITY_ENCRYPTION_NETWORK: c_int = 24;
@@ -50,9 +48,6 @@ pub const SO_ATTACH_FILTER: c_int = 26;
5048
pub const SO_DETACH_FILTER: c_int = 27;
5149
pub const SO_GET_FILTER: c_int = SO_ATTACH_FILTER;
5250
pub const SO_PEERNAME: c_int = 28;
53-
const SO_TIMESTAMP_OLD: c_int = 29;
54-
const SO_TIMESTAMPNS_OLD: c_int = 35;
55-
const SO_TIMESTAMPING_OLD: c_int = 37;
5651

5752
cfg_if! {
5853
if #[cfg(all(
@@ -76,6 +71,12 @@ cfg_if! {
7671
pub const SO_RCVTIMEO: c_int = 66;
7772
pub const SO_SNDTIMEO: c_int = 67;
7873
} else {
74+
const SO_TIMESTAMP_OLD: c_int = 29;
75+
const SO_TIMESTAMPNS_OLD: c_int = 35;
76+
const SO_TIMESTAMPING_OLD: c_int = 37;
77+
const SO_RCVTIMEO_OLD: c_int = 20;
78+
const SO_SNDTIMEO_OLD: c_int = 21;
79+
7980
pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_OLD;
8081
pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_OLD;
8182
pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_OLD;

src/unix/linux_like/linux/arch/mips/mod.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,17 @@ pub const SO_SNDBUF: c_int = 0x1001;
3333
pub const SO_RCVBUF: c_int = 0x1002;
3434
pub const SO_SNDLOWAT: c_int = 0x1003;
3535
pub const SO_RCVLOWAT: c_int = 0x1004;
36-
// NOTE: These definitions are now being renamed with _OLD postfix,
37-
// but CI haven't support them yet.
38-
// Some related consts could be found in b32.rs and b64.rs
39-
const SO_SNDTIMEO_OLD: c_int = 0x1005;
40-
const SO_RCVTIMEO_OLD: c_int = 0x1006;
4136
cfg_if! {
4237
if #[cfg(linux_time_bits64)] {
38+
const SO_RCVTIMEO_NEW: c_int = 66;
39+
const SO_SNDTIMEO_NEW: c_int = 67;
40+
4341
pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_NEW;
4442
pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_NEW;
4543
} else {
44+
const SO_SNDTIMEO_OLD: c_int = 0x1005;
45+
const SO_RCVTIMEO_OLD: c_int = 0x1006;
46+
4647
pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_OLD;
4748
pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_OLD;
4849
}
@@ -95,28 +96,27 @@ pub const SO_ZEROCOPY: c_int = 60;
9596
pub const SO_TXTIME: c_int = 61;
9697
pub const SCM_TXTIME: c_int = SO_TXTIME;
9798
pub const SO_BINDTOIFINDEX: c_int = 62;
98-
// NOTE: These definitions are now being renamed with _OLD postfix,
99-
// but CI haven't support them yet.
100-
// Some related consts could be found in b32.rs and b64.rs
101-
const SO_TIMESTAMP_OLD: c_int = 29;
102-
const SO_RCVTIMEO_NEW: c_int = 66;
103-
const SO_SNDTIMEO_NEW: c_int = 67;
104-
const SO_TIMESTAMPNS_OLD: c_int = 35;
105-
const SO_TIMESTAMPING_OLD: c_int = 37;
106-
const SO_TIMESTAMP_NEW: c_int = 63;
107-
const SO_TIMESTAMPNS_NEW: c_int = 64;
108-
const SO_TIMESTAMPING_NEW: c_int = 65;
99+
109100
cfg_if! {
110101
if #[cfg(linux_time_bits64)] {
102+
const SO_TIMESTAMP_NEW: c_int = 63;
103+
const SO_TIMESTAMPNS_NEW: c_int = 64;
104+
const SO_TIMESTAMPING_NEW: c_int = 65;
105+
111106
pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_NEW;
112107
pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_NEW;
113108
pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_NEW;
114109
} else {
110+
const SO_TIMESTAMP_OLD: c_int = 29;
111+
const SO_TIMESTAMPNS_OLD: c_int = 35;
112+
const SO_TIMESTAMPING_OLD: c_int = 37;
113+
115114
pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_OLD;
116115
pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_OLD;
117116
pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_OLD;
118117
}
119118
}
119+
120120
// pub const SO_DETACH_REUSEPORT_BPF: c_int = 68;
121121
pub const SO_PREFER_BUSY_POLL: c_int = 69;
122122
pub const SO_BUSY_POLL_BUDGET: c_int = 70;

src/unix/linux_like/linux/arch/powerpc/mod.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,23 @@ pub const SO_REUSEPORT: c_int = 15;
2424
// powerpc only differs in these
2525
pub const SO_RCVLOWAT: c_int = 16;
2626
pub const SO_SNDLOWAT: c_int = 17;
27+
2728
cfg_if! {
2829
if #[cfg(linux_time_bits64)] {
29-
pub const SO_SNDTIMEO: c_int = 67;
30-
pub const SO_RCVTIMEO: c_int = 66;
30+
const SO_RCVTIMEO_NEW: c_int = 66;
31+
const SO_SNDTIMEO_NEW: c_int = 67;
32+
33+
pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_NEW;
34+
pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_NEW;
3135
} else {
32-
pub const SO_SNDTIMEO: c_int = 19;
33-
pub const SO_RCVTIMEO: c_int = 18;
36+
const SO_RCVTIMEO_OLD: c_int = 18;
37+
const SO_SNDTIMEO_OLD: c_int = 19;
38+
39+
pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_OLD;
40+
pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_OLD;
3441
}
3542
}
36-
// pub const SO_RCVTIMEO_OLD: c_int = 18;
37-
// pub const SO_SNDTIMEO_OLD: c_int = 19;
43+
3844
pub const SO_PASSCRED: c_int = 20;
3945
pub const SO_PEERCRED: c_int = 21;
4046
// end
@@ -48,18 +54,23 @@ pub const SO_GET_FILTER: c_int = SO_ATTACH_FILTER;
4854
pub const SO_PEERNAME: c_int = 28;
4955
cfg_if! {
5056
if #[cfg(linux_time_bits64)] {
57+
const SO_TIMESTAMP_NEW: c_int = 63;
58+
const SO_TIMESTAMPNS_NEW: c_int = 64;
59+
const SO_TIMESTAMPING_NEW: c_int = 65;
60+
5161
pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_NEW;
5262
pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_NEW;
5363
pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_NEW;
5464
} else {
65+
const SO_TIMESTAMP_OLD: c_int = 29;
66+
const SO_TIMESTAMPNS_OLD: c_int = 35;
67+
const SO_TIMESTAMPING_OLD: c_int = 37;
68+
5569
pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_OLD;
5670
pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_OLD;
5771
pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_OLD;
5872
}
5973
}
60-
const SO_TIMESTAMP_OLD: c_int = 29;
61-
const SO_TIMESTAMPNS_OLD: c_int = 35;
62-
const SO_TIMESTAMPING_OLD: c_int = 37;
6374
pub const SO_ACCEPTCONN: c_int = 30;
6475
pub const SO_PEERSEC: c_int = 31;
6576
pub const SO_SNDBUFFORCE: c_int = 32;
@@ -94,11 +105,6 @@ pub const SO_ZEROCOPY: c_int = 60;
94105
pub const SO_TXTIME: c_int = 61;
95106
pub const SCM_TXTIME: c_int = SO_TXTIME;
96107
pub const SO_BINDTOIFINDEX: c_int = 62;
97-
const SO_TIMESTAMP_NEW: c_int = 63;
98-
const SO_TIMESTAMPNS_NEW: c_int = 64;
99-
const SO_TIMESTAMPING_NEW: c_int = 65;
100-
const SO_RCVTIMEO_NEW: c_int = 66;
101-
const SO_SNDTIMEO_NEW: c_int = 67;
102108
// pub const SO_DETACH_REUSEPORT_BPF: c_int = 68;
103109
pub const SO_PREFER_BUSY_POLL: c_int = 69;
104110
pub const SO_BUSY_POLL_BUDGET: c_int = 70;

src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ pub type wchar_t = c_int;
77

88
pub type nlink_t = c_uint;
99
pub type blksize_t = c_int;
10-
pub type fsblkcnt64_t = c_ulong;
11-
pub type fsfilcnt64_t = c_ulong;
1210
pub type __u64 = c_ulonglong;
1311
pub type __s64 = c_longlong;
1412

src/unix/linux_like/linux/uclibc/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// FIXME(ulibc): this module has definitions that are redundant with the parent
2+
#![allow(dead_code)]
3+
14
use crate::off64_t;
25
use crate::prelude::*;
36

src/unix/redox/mod.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,14 +1258,6 @@ extern "C" {
12581258
) -> ssize_t;
12591259
pub fn recvmsg(socket: c_int, msg: *mut msghdr, flags: c_int) -> ssize_t;
12601260
pub fn sendmsg(socket: c_int, msg: *const msghdr, flags: c_int) -> ssize_t;
1261-
pub fn sendto(
1262-
socket: c_int,
1263-
buf: *const c_void,
1264-
len: size_t,
1265-
flags: c_int,
1266-
addr: *const crate::sockaddr,
1267-
addrlen: crate::socklen_t,
1268-
) -> ssize_t;
12691261

12701262
// sys/stat.h
12711263
pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int;

src/unix/solarish/compat.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ use core::cmp::min;
55
use crate::unix::solarish::*;
66
use crate::{c_char, c_int, size_t};
77

8-
const PTEM: &[u8] = b"ptem\0";
9-
const LDTERM: &[u8] = b"ldterm\0";
10-
118
pub unsafe fn cfmakeraw(termios: *mut crate::termios) {
129
(*termios).c_iflag &=
1310
!(IMAXBEL | IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
@@ -41,6 +38,7 @@ pub unsafe fn cfsetspeed(termios: *mut crate::termios, speed: crate::speed_t) ->
4138
0
4239
}
4340

41+
#[cfg(target_os = "illumos")]
4442
unsafe fn bail(fdm: c_int, fds: c_int) -> c_int {
4543
let e = *___errno();
4644
if fds >= 0 {
@@ -61,6 +59,9 @@ pub unsafe fn openpty(
6159
termp: *const termios,
6260
winp: *const crate::winsize,
6361
) -> c_int {
62+
const PTEM: &[u8] = b"ptem\0";
63+
const LDTERM: &[u8] = b"ldterm\0";
64+
6465
// Open the main pseudo-terminal device, making sure not to set it as the
6566
// controlling terminal for this process:
6667
let fdm = crate::posix_openpt(O_RDWR | O_NOCTTY);

0 commit comments

Comments
 (0)