diff options
| author | Thomas de Zeeuw <thomasdezeeuw@gmail.com> | 2020-09-11 19:12:06 +0200 |
|---|---|---|
| committer | Thomas de Zeeuw <thomasdezeeuw@gmail.com> | 2020-09-11 19:12:06 +0200 |
| commit | c394624471c66c42bd9641ab30d2a2ccea894dbc (patch) | |
| tree | e09e6c375ed9c19d0b4c8cfe9237177d0f83fcde /library/std/src/sys/unix/process/process_unix.rs | |
| parent | 7c3e1ffd7a945b4044e5e80d7d74ba944ff54d0f (diff) | |
| download | rust-c394624471c66c42bd9641ab30d2a2ccea894dbc.tar.gz rust-c394624471c66c42bd9641ab30d2a2ccea894dbc.zip | |
Ignore unnecessary unsafe warnings
This is a work-around for a libc issue: https://github.com/rust-lang/libc/issues/1888.
Diffstat (limited to 'library/std/src/sys/unix/process/process_unix.rs')
| -rw-r--r-- | library/std/src/sys/unix/process/process_unix.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/library/std/src/sys/unix/process/process_unix.rs b/library/std/src/sys/unix/process/process_unix.rs index 0f349dfa302..08efe154e4c 100644 --- a/library/std/src/sys/unix/process/process_unix.rs +++ b/library/std/src/sys/unix/process/process_unix.rs @@ -459,7 +459,15 @@ impl ExitStatus { } fn exited(&self) -> bool { - unsafe { libc::WIFEXITED(self.0) } + // On Linux-like OSes this function is safe, on others it is not. See + // libc issue: https://github.com/rust-lang/libc/issues/1888. + #[cfg_attr( + any(target_os = "linux", target_os = "android", target_os = "emscripten"), + allow(unused_unsafe) + )] + unsafe { + libc::WIFEXITED(self.0) + } } pub fn success(&self) -> bool { @@ -467,10 +475,22 @@ impl ExitStatus { } pub fn code(&self) -> Option<i32> { + // On Linux-like OSes this function is safe, on others it is not. See + // libc issue: https://github.com/rust-lang/libc/issues/1888. + #[cfg_attr( + any(target_os = "linux", target_os = "android", target_os = "emscripten"), + allow(unused_unsafe) + )] if self.exited() { Some(unsafe { libc::WEXITSTATUS(self.0) }) } else { None } } pub fn signal(&self) -> Option<i32> { + // On Linux-like OSes this function is safe, on others it is not. See + // libc issue: https://github.com/rust-lang/libc/issues/1888. + #[cfg_attr( + any(target_os = "linux", target_os = "android", target_os = "emscripten"), + allow(unused_unsafe) + )] if !self.exited() { Some(unsafe { libc::WTERMSIG(self.0) }) } else { None } } } |
