Skip to content

Commit 2ced7ea

Browse files
committed
fix(unsafe): remove unnecessary unsafe
closes #1380 libc 0.2.82 exposes status signals with macros generating safe functions
1 parent eaa7ffb commit 2ced7ea

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

src/sys/wait.rs

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -116,59 +116,50 @@ impl WaitStatus {
116116
}
117117
}
118118

119-
#[allow(unused_unsafe)]
120119
fn exited(status: i32) -> bool {
121-
unsafe { libc::WIFEXITED(status) }
120+
libc::WIFEXITED(status)
122121
}
123122

124-
#[allow(unused_unsafe)]
125123
fn exit_status(status: i32) -> i32 {
126-
unsafe { libc::WEXITSTATUS(status) }
124+
libc::WEXITSTATUS(status)
127125
}
128126

129-
#[allow(unused_unsafe)]
130127
fn signaled(status: i32) -> bool {
131-
unsafe { libc::WIFSIGNALED(status) }
128+
libc::WIFSIGNALED(status)
132129
}
133130

134-
#[allow(unused_unsafe)]
135131
fn term_signal(status: i32) -> Result<Signal> {
136-
Signal::try_from(unsafe { libc::WTERMSIG(status) })
132+
Signal::try_from(libc::WTERMSIG(status))
137133
}
138134

139-
#[allow(unused_unsafe)]
140135
fn dumped_core(status: i32) -> bool {
141-
unsafe { libc::WCOREDUMP(status) }
136+
libc::WCOREDUMP(status)
142137
}
143138

144-
#[allow(unused_unsafe)]
145139
fn stopped(status: i32) -> bool {
146-
unsafe { libc::WIFSTOPPED(status) }
140+
libc::WIFSTOPPED(status)
147141
}
148142

149-
#[allow(unused_unsafe)]
150143
fn stop_signal(status: i32) -> Result<Signal> {
151-
Signal::try_from(unsafe { libc::WSTOPSIG(status) })
144+
Signal::try_from(libc::WSTOPSIG(status))
152145
}
153146

154147
#[cfg(any(target_os = "android", target_os = "linux"))]
155-
#[allow(unused_unsafe)]
156148
fn syscall_stop(status: i32) -> bool {
157149
// From ptrace(2), setting PTRACE_O_TRACESYSGOOD has the effect
158150
// of delivering SIGTRAP | 0x80 as the signal number for syscall
159151
// stops. This allows easily distinguishing syscall stops from
160152
// genuine SIGTRAP signals.
161-
unsafe { libc::WSTOPSIG(status) == libc::SIGTRAP | 0x80 }
153+
libc::WSTOPSIG(status) == libc::SIGTRAP | 0x80
162154
}
163155

164156
#[cfg(any(target_os = "android", target_os = "linux"))]
165157
fn stop_additional(status: i32) -> c_int {
166158
(status >> 16) as c_int
167159
}
168160

169-
#[allow(unused_unsafe)]
170161
fn continued(status: i32) -> bool {
171-
unsafe { libc::WIFCONTINUED(status) }
162+
libc::WIFCONTINUED(status)
172163
}
173164

174165
impl WaitStatus {

0 commit comments

Comments
 (0)