From 4db701dafedf6dacce465bb90d4594628b67dbf8 Mon Sep 17 00:00:00 2001 From: Vitaly _Vi Shukela Date: Sat, 12 Sep 2020 12:36:27 +0300 Subject: [PATCH] Adapt for safe-isation of some libc functions. (https://github.com/rust-lang/libc/pull/1870) Denied lint being overridden instead of unsafe block removed to preserve compatibility with old `libc` versions. --- src/sys/quota.rs | 1 + src/sys/wait.rs | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/sys/quota.rs b/src/sys/quota.rs index 1199d5f967..1933013219 100644 --- a/src/sys/quota.rs +++ b/src/sys/quota.rs @@ -21,6 +21,7 @@ use crate::errno::Errno; struct QuotaCmd(QuotaSubCmd, QuotaType); impl QuotaCmd { + #[allow(unused_unsafe)] fn as_int(&self) -> c_int { unsafe { libc::QCMD(self.0 as i32, self.1 as i32) } } diff --git a/src/sys/wait.rs b/src/sys/wait.rs index 9825102ceb..0c040427cc 100644 --- a/src/sys/wait.rs +++ b/src/sys/wait.rs @@ -117,35 +117,43 @@ impl WaitStatus { } } +#[allow(unused_unsafe)] fn exited(status: i32) -> bool { unsafe { libc::WIFEXITED(status) } } +#[allow(unused_unsafe)] fn exit_status(status: i32) -> i32 { unsafe { libc::WEXITSTATUS(status) } } +#[allow(unused_unsafe)] fn signaled(status: i32) -> bool { unsafe { libc::WIFSIGNALED(status) } } +#[allow(unused_unsafe)] fn term_signal(status: i32) -> Result { Signal::try_from(unsafe { libc::WTERMSIG(status) }) } +#[allow(unused_unsafe)] fn dumped_core(status: i32) -> bool { unsafe { libc::WCOREDUMP(status) } } +#[allow(unused_unsafe)] fn stopped(status: i32) -> bool { unsafe { libc::WIFSTOPPED(status) } } +#[allow(unused_unsafe)] fn stop_signal(status: i32) -> Result { Signal::try_from(unsafe { libc::WSTOPSIG(status) }) } #[cfg(any(target_os = "android", target_os = "linux"))] +#[allow(unused_unsafe)] fn syscall_stop(status: i32) -> bool { // From ptrace(2), setting PTRACE_O_TRACESYSGOOD has the effect // of delivering SIGTRAP | 0x80 as the signal number for syscall @@ -159,6 +167,7 @@ fn stop_additional(status: i32) -> c_int { (status >> 16) as c_int } +#[allow(unused_unsafe)] fn continued(status: i32) -> bool { unsafe { libc::WIFCONTINUED(status) } }