Skip to content

Commit 57603c6

Browse files
committed
Replace allow unused directive with _ prefix
1 parent da089f8 commit 57603c6

9 files changed

+26
-51
lines changed

src/pty.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ pub fn grantpt(fd: &PtyMaster) -> Result<()> {
108108
/// let slave_name = unsafe { ptsname(&master_fd) }?;
109109
///
110110
/// // Try to open the slave
111-
/// # #[allow(unused_variables)]
112-
/// let slave_fd = open(Path::new(&slave_name), OFlag::O_RDWR, Mode::empty())?;
111+
/// let _slave_fd = open(Path::new(&slave_name), OFlag::O_RDWR, Mode::empty())?;
113112
/// # Ok(())
114113
/// # }
115114
/// ```

test/sys/test_aio.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,7 @@ extern fn sigfunc(_: c_int) {
441441
#[test]
442442
#[cfg_attr(any(all(target_env = "musl", target_arch = "x86_64"), target_arch = "mips", target_arch = "mips64"), ignore)]
443443
fn test_write_sigev_signal() {
444-
#[allow(unused_variables)]
445-
let m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");
444+
let _m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");
446445
let sa = SigAction::new(SigHandler::Handler(sigfunc),
447446
SaFlags::SA_RESETHAND,
448447
SigSet::empty());
@@ -580,8 +579,7 @@ fn test_liocb_listio_nowait() {
580579
#[cfg(not(any(target_os = "ios", target_os = "macos")))]
581580
#[cfg_attr(any(target_arch = "mips", target_arch = "mips64", target_env = "musl"), ignore)]
582581
fn test_liocb_listio_signal() {
583-
#[allow(unused_variables)]
584-
let m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");
582+
let _m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");
585583
const INITIAL: &[u8] = b"abcdef123456";
586584
const WBUF: &[u8] = b"CDEF";
587585
let mut rbuf = vec![0; 4];

test/sys/test_signal.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ fn test_sigprocmask_noop() {
2828

2929
#[test]
3030
fn test_sigprocmask() {
31-
#[allow(unused_variables)]
32-
let m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");
31+
let _m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");
3332

3433
// This needs to be a signal that rust doesn't use in the test harness.
3534
const SIGNAL: Signal = Signal::SIGCHLD;

test/sys/test_signalfd.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ fn test_signalfd() {
44
use nix::sys::signal::{self, raise, Signal, SigSet};
55

66
// Grab the mutex for altering signals so we don't interfere with other tests.
7-
#[allow(unused_variables)]
8-
let m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");
7+
let _m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");
98

109
// Block the SIGUSR1 signal from automatic processing for this thread
1110
let mut mask = SigSet::empty();

test/sys/test_termios.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ fn write_all(f: RawFd, buf: &[u8]) {
1919
#[test]
2020
fn test_tcgetattr_pty() {
2121
// openpty uses ptname(3) internally
22-
#[allow(unused_variables)]
23-
let m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
22+
let _m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
2423

2524
let pty = openpty(None, None).expect("openpty failed");
2625
assert!(termios::tcgetattr(pty.master).is_ok());
@@ -47,8 +46,7 @@ fn test_tcgetattr_ebadf() {
4746
#[test]
4847
fn test_output_flags() {
4948
// openpty uses ptname(3) internally
50-
#[allow(unused_variables)]
51-
let m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
49+
let _m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
5250

5351
// Open one pty to get attributes for the second one
5452
let mut termios = {
@@ -90,8 +88,7 @@ fn test_output_flags() {
9088
#[test]
9189
fn test_local_flags() {
9290
// openpty uses ptname(3) internally
93-
#[allow(unused_variables)]
94-
let m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
91+
let _m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
9592

9693
// Open one pty to get attributes for the second one
9794
let mut termios = {

test/sys/test_uio.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,7 @@ fn test_process_vm_readv() {
200200
use nix::sys::signal::*;
201201
use nix::sys::wait::*;
202202

203-
#[allow(unused_variables)]
204-
let m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
203+
let _ = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
205204

206205
// Pre-allocate memory in the child, since allocation isn't safe
207206
// post-fork (~= async-signal-safe)

test/sys/test_wait.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ use libc::_exit;
77

88
#[test]
99
fn test_wait_signal() {
10-
#[allow(unused_variables)]
11-
let m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
10+
let _ = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
1211

1312
// Safe: The child only calls `pause` and/or `_exit`, which are async-signal-safe.
1413
match fork().expect("Error: Fork Failed") {
@@ -25,8 +24,7 @@ fn test_wait_signal() {
2524

2625
#[test]
2726
fn test_wait_exit() {
28-
#[allow(unused_variables)]
29-
let m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
27+
let _m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
3028

3129
// Safe: Child only calls `_exit`, which is async-signal-safe.
3230
match fork().expect("Error: Fork Failed") {
@@ -96,8 +94,7 @@ mod ptrace {
9694

9795
#[test]
9896
fn test_wait_ptrace() {
99-
#[allow(unused_variables)]
100-
let m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
97+
let _m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
10198

10299
match fork().expect("Error: Fork Failed") {
103100
Child => ptrace_child(),

test/test_pty.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ fn test_explicit_close() {
2727
#[test]
2828
#[cfg(any(target_os = "android", target_os = "linux"))]
2929
fn test_ptsname_equivalence() {
30-
#[allow(unused_variables)]
31-
let m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
30+
let _m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
3231

3332
// Open a new PTTY master
3433
let master_fd = posix_openpt(OFlag::O_RDWR).unwrap();
@@ -45,8 +44,7 @@ fn test_ptsname_equivalence() {
4544
#[test]
4645
#[cfg(any(target_os = "android", target_os = "linux"))]
4746
fn test_ptsname_copy() {
48-
#[allow(unused_variables)]
49-
let m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
47+
let _m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
5048

5149
// Open a new PTTY master
5250
let master_fd = posix_openpt(OFlag::O_RDWR).unwrap();
@@ -80,8 +78,7 @@ fn test_ptsname_r_copy() {
8078
#[test]
8179
#[cfg(any(target_os = "android", target_os = "linux"))]
8280
fn test_ptsname_unique() {
83-
#[allow(unused_variables)]
84-
let m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
81+
let _m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
8582

8683
// Open a new PTTY master
8784
let master1_fd = posix_openpt(OFlag::O_RDWR).unwrap();
@@ -103,9 +100,8 @@ fn test_ptsname_unique() {
103100
/// this test we perform the basic act of getting a file handle for a connect master/slave PTTY
104101
/// pair.
105102
#[test]
106-
fn test_open_ptty_pair() {
107-
#[allow(unused_variables)]
108-
let m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
103+
fn test_open_ptty_pair() {
104+
let _m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
109105

110106
// Open a new PTTY master
111107
let master_fd = posix_openpt(OFlag::O_RDWR).expect("posix_openpt failed");
@@ -126,8 +122,7 @@ fn test_open_ptty_pair() {
126122
#[test]
127123
fn test_openpty() {
128124
// openpty uses ptname(3) internally
129-
#[allow(unused_variables)]
130-
let m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
125+
let _m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
131126

132127
let pty = openpty(None, None).unwrap();
133128
assert!(pty.master > 0);
@@ -162,8 +157,7 @@ fn test_openpty() {
162157
#[test]
163158
fn test_openpty_with_termios() {
164159
// openpty uses ptname(3) internally
165-
#[allow(unused_variables)]
166-
let m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
160+
let _m = ::PTSNAME_MTX.lock().expect("Mutex got poisoned by another test");
167161

168162
// Open one pty to get attributes for the second one
169163
let mut termios = {

test/test_unistd.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ use libc::{self, _exit, off_t};
1414

1515
#[test]
1616
fn test_fork_and_waitpid() {
17-
#[allow(unused_variables)]
18-
let m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
17+
let _m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
1918

2019
// Safe: Child only calls `_exit`, which is signal-safe
2120
match fork().expect("Error: Fork Failed") {
@@ -43,8 +42,7 @@ fn test_fork_and_waitpid() {
4342
#[test]
4443
fn test_wait() {
4544
// Grab FORK_MTX so wait doesn't reap a different test's child process
46-
#[allow(unused_variables)]
47-
let m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
45+
let _m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
4846

4947
// Safe: Child only calls `_exit`, which is signal-safe
5048
match fork().expect("Error: Fork Failed") {
@@ -136,8 +134,7 @@ fn test_setgroups() {
136134
return;
137135
}
138136

139-
#[allow(unused_variables)]
140-
let m = ::GROUPS_MTX.lock().expect("Mutex got poisoned by another test");
137+
let _m = ::GROUPS_MTX.lock().expect("Mutex got poisoned by another test");
141138

142139
// Save the existing groups
143140
let old_groups = getgroups().unwrap();
@@ -166,8 +163,7 @@ fn test_initgroups() {
166163
return;
167164
}
168165

169-
#[allow(unused_variables)]
170-
let m = ::GROUPS_MTX.lock().expect("Mutex got poisoned by another test");
166+
let _m = ::GROUPS_MTX.lock().expect("Mutex got poisoned by another test");
171167

172168
// Save the existing groups
173169
let old_groups = getgroups().unwrap();
@@ -195,8 +191,7 @@ macro_rules! execve_test_factory(
195191
($test_name:ident, $syscall:ident, $exe: expr $(, $pathname:expr, $flags:expr)*) => (
196192
#[test]
197193
fn $test_name() {
198-
#[allow(unused_variables)]
199-
let m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
194+
let _m = ::FORK_MTX.lock().expect("Mutex got poisoned by another test");
200195
// The `exec`d process will write to `writer`, and we'll read that
201196
// data from `reader`.
202197
let (reader, writer) = pipe().unwrap();
@@ -280,8 +275,7 @@ cfg_if!{
280275
#[test]
281276
fn test_fchdir() {
282277
// fchdir changes the process's cwd
283-
#[allow(unused_variables)]
284-
let m = ::CWD_MTX.lock().expect("Mutex got poisoned by another test");
278+
let _m = ::CWD_MTX.lock().expect("Mutex got poisoned by another test");
285279

286280
let tmpdir = tempfile::tempdir().unwrap();
287281
let tmpdir_path = tmpdir.path().canonicalize().unwrap();
@@ -296,8 +290,7 @@ fn test_fchdir() {
296290
#[test]
297291
fn test_getcwd() {
298292
// chdir changes the process's cwd
299-
#[allow(unused_variables)]
300-
let m = ::CWD_MTX.lock().expect("Mutex got poisoned by another test");
293+
let _m = ::CWD_MTX.lock().expect("Mutex got poisoned by another test");
301294

302295
let tmpdir = tempfile::tempdir().unwrap();
303296
let tmpdir_path = tmpdir.path().canonicalize().unwrap();

0 commit comments

Comments
 (0)