Skip to content

Commit

Permalink
Suppress a build warning on Fuchsia
Browse files Browse the repository at this point in the history
Beginning with 1.41.0, Rust considers it UB to zero-initialize a
function pointer, even if you try to hide it behind `mem::MaybeUninit`.
Suppress this warning to fix the build until we come up with a better
permanent solution.

Issue #1441
  • Loading branch information
asomers committed May 30, 2021
1 parent 33df3e7 commit cd6525f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/sys/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -850,10 +850,10 @@ mod sigevent {
/// Linux, Solaris, and portable programs should prefer `SIGEV_THREAD_ID` or
/// `SIGEV_SIGNAL`. That field is part of a union that shares space with the
/// more genuinely useful `sigev_notify_thread_id`
// Allow invalid_value warning on Fuchsia only.
// See https://github.com/nix-rust/nix/issues/1441
#[cfg_attr(target_os = "fuchsia", allow(invalid_value))]
pub fn new(sigev_notify: SigevNotify) -> SigEvent {
// NB: This uses MaybeUninit rather than mem::zeroed because libc::sigevent contains a
// function pointer on Fuchsia as of https://github.com/rust-lang/libc/commit/2f59370,
// and function pointers must not be null.
let mut sev = unsafe { mem::MaybeUninit::<libc::sigevent>::zeroed().assume_init() };
sev.sigev_notify = match sigev_notify {
SigevNotify::SigevNone => libc::SIGEV_NONE,
Expand Down

0 comments on commit cd6525f

Please sign in to comment.