Skip to content

Commit

Permalink
Adapt for safe-isation of some libc functions.
Browse files Browse the repository at this point in the history
(rust-lang/libc#1870)

Denied lint being overridden instead of unsafe block removed
to preserve compatibility with old `libc` versions.
  • Loading branch information
vi authored and yoav-steinberg committed Oct 4, 2020
1 parent 9575b29 commit 86f1d7e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/sys/quota.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
Expand Down
9 changes: 9 additions & 0 deletions src/sys/wait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
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> {
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
Expand All @@ -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) }
}
Expand Down

0 comments on commit 86f1d7e

Please sign in to comment.