Skip to content

Commit a3c60fc

Browse files
committed
Allow unused_unsafe warning
Use #[allow(unused_unsafe)] to work around inconsitency with fn unsafe in libc after [#1870](rust-lang/libc#1870) change.
1 parent bbdc1cf commit a3c60fc

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

src/sys/quota.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ struct QuotaCmd(QuotaSubCmd, QuotaType);
2323
impl QuotaCmd {
2424
#[allow(unused_unsafe)]
2525
fn as_int(&self) -> c_int {
26-
libc::QCMD(self.0 as i32, self.1 as i32)
26+
#[allow(unused_unsafe)]
27+
unsafe { libc::QCMD(self.0 as i32, self.1 as i32) }
2728
}
2829
}
2930

src/sys/wait.rs

+18-9
Original file line numberDiff line numberDiff line change
@@ -119,37 +119,44 @@ impl WaitStatus {
119119

120120
#[allow(unused_unsafe)]
121121
fn exited(status: i32) -> bool {
122-
libc::WIFEXITED(status)
122+
#[allow(unused_unsafe)]
123+
unsafe { libc::WIFEXITED(status) }
123124
}
124125

125126
#[allow(unused_unsafe)]
126127
fn exit_status(status: i32) -> i32 {
127-
libc::WEXITSTATUS(status)
128+
#[allow(unused_unsafe)]
129+
unsafe { libc::WEXITSTATUS(status) }
128130
}
129131

130132
#[allow(unused_unsafe)]
131133
fn signaled(status: i32) -> bool {
132-
libc::WIFSIGNALED(status)
134+
#[allow(unused_unsafe)]
135+
unsafe { libc::WIFSIGNALED(status) }
133136
}
134137

135138
#[allow(unused_unsafe)]
136139
fn term_signal(status: i32) -> Result<Signal> {
137-
Signal::try_from(libc::WTERMSIG(status))
140+
#[allow(unused_unsafe)]
141+
Signal::try_from(unsafe { libc::WTERMSIG(status) })
138142
}
139143

140144
#[allow(unused_unsafe)]
141145
fn dumped_core(status: i32) -> bool {
142-
libc::WCOREDUMP(status)
146+
#[allow(unused_unsafe)]
147+
unsafe { libc::WCOREDUMP(status) }
143148
}
144149

145150
#[allow(unused_unsafe)]
146151
fn stopped(status: i32) -> bool {
147-
libc::WIFSTOPPED(status)
152+
#[allow(unused_unsafe)]
153+
unsafe { libc::WIFSTOPPED(status) }
148154
}
149155

150156
#[allow(unused_unsafe)]
151157
fn stop_signal(status: i32) -> Result<Signal> {
152-
Signal::try_from(libc::WSTOPSIG(status))
158+
#[allow(unused_unsafe)]
159+
Signal::try_from(unsafe { libc::WSTOPSIG(status) })
153160
}
154161

155162
#[cfg(any(target_os = "android", target_os = "linux"))]
@@ -159,7 +166,8 @@ fn syscall_stop(status: i32) -> bool {
159166
// of delivering SIGTRAP | 0x80 as the signal number for syscall
160167
// stops. This allows easily distinguishing syscall stops from
161168
// genuine SIGTRAP signals.
162-
libc::WSTOPSIG(status) == libc::SIGTRAP | 0x80
169+
#[allow(unused_unsafe)]
170+
unsafe { libc::WSTOPSIG(status) == libc::SIGTRAP | 0x80 }
163171
}
164172

165173
#[cfg(any(target_os = "android", target_os = "linux"))]
@@ -169,7 +177,8 @@ fn stop_additional(status: i32) -> c_int {
169177

170178
#[allow(unused_unsafe)]
171179
fn continued(status: i32) -> bool {
172-
libc::WIFCONTINUED(status)
180+
#[allow(unused_unsafe)]
181+
unsafe { libc::WIFCONTINUED(status) }
173182
}
174183

175184
impl WaitStatus {

0 commit comments

Comments
 (0)