diff --git a/src/sys/signalfd.rs b/src/sys/signalfd.rs index 9d5de0362f..00a5d2b5ef 100644 --- a/src/sys/signalfd.rs +++ b/src/sys/signalfd.rs @@ -34,7 +34,8 @@ libc_bitflags!{ } pub const SIGNALFD_NEW: RawFd = -1; -pub const SIGNALFD_SIGINFO_SIZE: usize = mem::size_of::(); +#[deprecated(since = "0.23.0", note = "use mem::size_of::() instead")] +pub const SIGNALFD_SIGINFO_SIZE: usize = mem::size_of::(); /// Creates a new file descriptor for reading signals. /// @@ -98,15 +99,16 @@ impl SignalFd { } pub fn read_signal(&mut self) -> Result> { - let mut buffer = mem::MaybeUninit::<[u8; SIGNALFD_SIGINFO_SIZE]>::uninit(); + let mut buffer = mem::MaybeUninit::::uninit(); let res = Errno::result(unsafe { libc::read(self.0, buffer.as_mut_ptr() as *mut libc::c_void, - SIGNALFD_SIGINFO_SIZE as libc::size_t) + mem::size_of_val(*buffer)) }).map(|r| r as usize); match res { - Ok(SIGNALFD_SIGINFO_SIZE) => Ok(Some(unsafe { mem::transmute(buffer.assume_init()) })), + Ok(mem::size_of_val(*buffer)) => + Ok(Some(unsafe { buffer.assume_init() })), Ok(_) => unreachable!("partial read on signalfd"), Err(Errno::EAGAIN) => Ok(None), Err(error) => Err(error)