From e4255077eb08d865d444bab9331cd5fa4039fdb7 Mon Sep 17 00:00:00 2001 From: Alex Saveau Date: Sat, 3 Dec 2022 13:40:32 -0800 Subject: [PATCH] Fix clippy lints Signed-off-by: Alex Saveau --- src/sys/aio.rs | 2 +- src/sys/mman.rs | 13 ++++---- src/sys/socket/addr.rs | 68 +++++++++++++++++++++------------------ src/sys/socket/mod.rs | 1 - src/sys/socket/sockopt.rs | 7 ++-- src/sys/time.rs | 32 +++++++++--------- test/sys/test_aio.rs | 2 +- test/sys/test_signal.rs | 8 ++--- test/sys/test_socket.rs | 12 +++---- test/test_fcntl.rs | 2 +- test/test_mount.rs | 42 +++++++++++------------- test/test_unistd.rs | 13 +++----- 12 files changed, 95 insertions(+), 107 deletions(-) diff --git a/src/sys/aio.rs b/src/sys/aio.rs index e2ce19b79d..ee78d9c2f0 100644 --- a/src/sys/aio.rs +++ b/src/sys/aio.rs @@ -163,7 +163,7 @@ impl AioCb { 0 => Ok(()), num if num > 0 => Err(Errno::from_i32(num)), -1 => Err(Errno::last()), - num => panic!("unknown aio_error return value {:?}", num), + num => panic!("unknown aio_error return value {num:?}"), } } diff --git a/src/sys/mman.rs b/src/sys/mman.rs index 2bee091610..d4c6ecb05e 100644 --- a/src/sys/mman.rs +++ b/src/sys/mman.rs @@ -8,7 +8,7 @@ use crate::Result; #[cfg(feature = "fs")] use crate::{fcntl::OFlag, sys::stat::Mode}; use libc::{self, c_int, c_void, off_t, size_t}; -use std::{os::unix::io::RawFd, num::NonZeroUsize}; +use std::{num::NonZeroUsize, os::unix::io::RawFd}; libc_bitflags! { /// Desired memory protection of a memory mapping. @@ -424,12 +424,11 @@ pub unsafe fn mmap( fd: RawFd, offset: off_t, ) -> Result<*mut c_void> { - let ptr = addr.map_or( - std::ptr::null_mut(), - |a| usize::from(a) as *mut c_void - ); - - let ret = libc::mmap(ptr, length.into(), prot.bits(), flags.bits(), fd, offset); + let ptr = + addr.map_or(std::ptr::null_mut(), |a| usize::from(a) as *mut c_void); + + let ret = + libc::mmap(ptr, length.into(), prot.bits(), flags.bits(), fd, offset); if ret == libc::MAP_FAILED { Err(Errno::last()) diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs index 970e838122..04bddf2593 100644 --- a/src/sys/socket/addr.rs +++ b/src/sys/socket/addr.rs @@ -42,9 +42,7 @@ pub(crate) const fn ipv4addr_to_libc(addr: net::Ipv4Addr) -> libc::in_addr { static_assertions::assert_eq_size!(net::Ipv4Addr, libc::in_addr); // Safe because both types have the same memory layout, and no fancy Drop // impls. - unsafe { - mem::transmute(addr) - } + unsafe { mem::transmute(addr) } } /// Convert a std::net::Ipv6Addr into the libc form. @@ -52,9 +50,7 @@ pub(crate) const fn ipv4addr_to_libc(addr: net::Ipv4Addr) -> libc::in_addr { pub(crate) const fn ipv6addr_to_libc(addr: &net::Ipv6Addr) -> libc::in6_addr { static_assertions::assert_eq_size!(net::Ipv6Addr, libc::in6_addr); // Safe because both are Newtype wrappers around the same libc type - unsafe { - mem::transmute(*addr) - } + unsafe { mem::transmute(*addr) } } /// These constants specify the protocol family to be used @@ -79,7 +75,11 @@ pub enum AddressFamily { #[cfg_attr(docsrs, doc(cfg(all())))] Netlink = libc::AF_NETLINK, /// Kernel interface for interacting with the routing table - #[cfg(not(any(target_os = "redox", target_os = "linux", target_os = "android")))] + #[cfg(not(any( + target_os = "redox", + target_os = "linux", + target_os = "android" + )))] Route = libc::PF_ROUTE, /// Low level packet interface (see [`packet(7)`](https://man7.org/linux/man-pages/man7/packet.7.html)) #[cfg(any( @@ -422,7 +422,11 @@ impl AddressFamily { libc::AF_NETLINK => Some(AddressFamily::Netlink), #[cfg(any(target_os = "macos", target_os = "macos"))] libc::AF_SYSTEM => Some(AddressFamily::System), - #[cfg(not(any(target_os = "redox", target_os = "linux", target_os = "android")))] + #[cfg(not(any( + target_os = "redox", + target_os = "linux", + target_os = "android" + )))] libc::PF_ROUTE => Some(AddressFamily::Route), #[cfg(any(target_os = "android", target_os = "linux"))] libc::AF_PACKET => Some(AddressFamily::Packet), @@ -592,10 +596,11 @@ impl UnixAddr { pub fn new_unnamed() -> UnixAddr { let ret = libc::sockaddr_un { sun_family: AddressFamily::Unix as sa_family_t, - .. unsafe { mem::zeroed() } + ..unsafe { mem::zeroed() } }; - let sun_len: u8 = offset_of!(libc::sockaddr_un, sun_path).try_into().unwrap(); + let sun_len: u8 = + offset_of!(libc::sockaddr_un, sun_path).try_into().unwrap(); unsafe { UnixAddr::from_raw_parts(ret, sun_len) } } @@ -1268,7 +1273,9 @@ impl SockaddrLike for SockaddrStorage { if i32::from(ss.ss_family) == libc::AF_UNIX { // Safe because we UnixAddr is strictly smaller than // SockaddrStorage, and we just initialized the structure. - (*(&mut ss as *mut libc::sockaddr_storage as *mut UnixAddr)).sun_len = len as u8; + (*(&mut ss as *mut libc::sockaddr_storage + as *mut UnixAddr)) + .sun_len = len as u8; } Some(Self { ss }) } @@ -1343,7 +1350,7 @@ impl SockaddrLike for SockaddrStorage { // The UnixAddr type knows its own length Some(ua) => ua.len(), // For all else, we're just a boring SockaddrStorage - None => mem::size_of_val(self) as libc::socklen_t + None => mem::size_of_val(self) as libc::socklen_t, } } } @@ -1403,12 +1410,13 @@ impl SockaddrStorage { } } // Sanity checks - if self.family() != Some(AddressFamily::Unix) || - len < offset_of!(libc::sockaddr_un, sun_path) || - len > mem::size_of::() { + if self.family() != Some(AddressFamily::Unix) + || len < offset_of!(libc::sockaddr_un, sun_path) + || len > mem::size_of::() + { None } else { - Some(unsafe{&self.su}) + Some(unsafe { &self.su }) } } @@ -1432,12 +1440,13 @@ impl SockaddrStorage { } } // Sanity checks - if self.family() != Some(AddressFamily::Unix) || - len < offset_of!(libc::sockaddr_un, sun_path) || - len > mem::size_of::() { + if self.family() != Some(AddressFamily::Unix) + || len < offset_of!(libc::sockaddr_un, sun_path) + || len > mem::size_of::() + { None } else { - Some(unsafe{&mut self.su}) + Some(unsafe { &mut self.su }) } } @@ -2486,7 +2495,7 @@ mod tests { fn display() { let s = "127.0.0.1:8080"; let addr = SockaddrIn::from_str(s).unwrap(); - assert_eq!(s, format!("{}", addr)); + assert_eq!(s, format!("{addr}")); } #[test] @@ -2506,7 +2515,7 @@ mod tests { fn display() { let s = "[1234:5678:90ab:cdef::1111:2222]:8080"; let addr = SockaddrIn6::from_str(s).unwrap(); - assert_eq!(s, format!("{}", addr)); + assert_eq!(s, format!("{addr}")); } #[test] @@ -2525,9 +2534,8 @@ mod tests { fn from_sockaddr_un_named() { let ua = UnixAddr::new("/var/run/mysock").unwrap(); let ptr = ua.as_ptr() as *const libc::sockaddr; - let ss = unsafe { - SockaddrStorage::from_raw(ptr, Some(ua.len())) - }.unwrap(); + let ss = unsafe { SockaddrStorage::from_raw(ptr, Some(ua.len())) } + .unwrap(); assert_eq!(ss.len(), ua.len()); } @@ -2537,9 +2545,8 @@ mod tests { let name = String::from("nix\0abstract\0test"); let ua = UnixAddr::new_abstract(name.as_bytes()).unwrap(); let ptr = ua.as_ptr() as *const libc::sockaddr; - let ss = unsafe { - SockaddrStorage::from_raw(ptr, Some(ua.len())) - }.unwrap(); + let ss = unsafe { SockaddrStorage::from_raw(ptr, Some(ua.len())) } + .unwrap(); assert_eq!(ss.len(), ua.len()); } @@ -2548,9 +2555,8 @@ mod tests { fn from_sockaddr_un_abstract_unnamed() { let ua = UnixAddr::new_unnamed(); let ptr = ua.as_ptr() as *const libc::sockaddr; - let ss = unsafe { - SockaddrStorage::from_raw(ptr, Some(ua.len())) - }.unwrap(); + let ss = unsafe { SockaddrStorage::from_raw(ptr, Some(ua.len())) } + .unwrap(); assert_eq!(ss.len(), ua.len()); } } diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index 5a16417131..0e2bd62d8c 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -12,7 +12,6 @@ use libc::{ self, c_int, c_void, iovec, size_t, socklen_t, CMSG_DATA, CMSG_FIRSTHDR, CMSG_LEN, CMSG_NXTHDR, }; -use std::convert::TryFrom; use std::io::{IoSlice, IoSliceMut}; #[cfg(feature = "net")] use std::net; diff --git a/src/sys/socket/sockopt.rs b/src/sys/socket/sockopt.rs index 06e9ee4563..c2daeae7a0 100644 --- a/src/sys/socket/sockopt.rs +++ b/src/sys/socket/sockopt.rs @@ -6,10 +6,7 @@ use crate::Result; use cfg_if::cfg_if; use libc::{self, c_int, c_void, socklen_t}; use std::ffi::{OsStr, OsString}; -use std::{ - convert::TryFrom, - mem::{self, MaybeUninit} -}; +use std::mem::{self, MaybeUninit}; #[cfg(target_family = "unix")] use std::os::unix::ffi::OsStrExt; use std::os::unix::io::RawFd; @@ -107,7 +104,7 @@ macro_rules! getsockopt_impl { match <$ty>::try_from(getter.assume_init()) { Err(_) => Err(Errno::EINVAL), - Ok(r) => Ok(r) + Ok(r) => Ok(r), } } } diff --git a/src/sys/time.rs b/src/sys/time.rs index 0042c45084..a1894e4d54 100644 --- a/src/sys/time.rs +++ b/src/sys/time.rs @@ -261,8 +261,7 @@ impl TimeValLike for TimeSpec { fn seconds(seconds: i64) -> TimeSpec { assert!( (TS_MIN_SECONDS..=TS_MAX_SECONDS).contains(&seconds), - "TimeSpec out of bounds; seconds={}", - seconds + "TimeSpec out of bounds; seconds={seconds}", ); let mut ts = zero_init_timespec(); ts.tv_sec = seconds as time_t; @@ -428,20 +427,20 @@ impl fmt::Display for TimeSpec { let sec = abs.tv_sec(); - write!(f, "{}", sign)?; + write!(f, "{sign}")?; if abs.tv_nsec() == 0 { - if abs.tv_sec() == 1 { - write!(f, "{} second", sec)?; + if sec == 1 { + write!(f, "1 second")?; } else { - write!(f, "{} seconds", sec)?; + write!(f, "{sec} seconds")?; } } else if abs.tv_nsec() % 1_000_000 == 0 { - write!(f, "{}.{:03} seconds", sec, abs.tv_nsec() / 1_000_000)?; + write!(f, "{sec}.{:03} seconds", abs.tv_nsec() / 1_000_000)?; } else if abs.tv_nsec() % 1_000 == 0 { - write!(f, "{}.{:06} seconds", sec, abs.tv_nsec() / 1_000)?; + write!(f, "{sec}.{:06} seconds", abs.tv_nsec() / 1_000)?; } else { - write!(f, "{}.{:09} seconds", sec, abs.tv_nsec())?; + write!(f, "{sec}.{:09} seconds", abs.tv_nsec())?; } Ok(()) @@ -497,8 +496,7 @@ impl TimeValLike for TimeVal { fn seconds(seconds: i64) -> TimeVal { assert!( (TV_MIN_SECONDS..=TV_MAX_SECONDS).contains(&seconds), - "TimeVal out of bounds; seconds={}", - seconds + "TimeVal out of bounds; seconds={seconds}" ); #[cfg_attr(target_env = "musl", allow(deprecated))] // https://github.com/rust-lang/libc/issues/1848 @@ -662,18 +660,18 @@ impl fmt::Display for TimeVal { let sec = abs.tv_sec(); - write!(f, "{}", sign)?; + write!(f, "{sign}")?; if abs.tv_usec() == 0 { - if abs.tv_sec() == 1 { - write!(f, "{} second", sec)?; + if sec == 1 { + write!(f, "1 second")?; } else { - write!(f, "{} seconds", sec)?; + write!(f, "{sec} seconds")?; } } else if abs.tv_usec() % 1000 == 0 { - write!(f, "{}.{:03} seconds", sec, abs.tv_usec() / 1000)?; + write!(f, "{sec}.{:03} seconds", abs.tv_usec() / 1000)?; } else { - write!(f, "{}.{:06} seconds", sec, abs.tv_usec())?; + write!(f, "{sec}.{:06} seconds", abs.tv_usec())?; } Ok(()) diff --git a/test/sys/test_aio.rs b/test/sys/test_aio.rs index 84086f80ce..fdabaca6aa 100644 --- a/test/sys/test_aio.rs +++ b/test/sys/test_aio.rs @@ -610,7 +610,7 @@ fn test_aio_suspend() { let r = aio_suspend(&cbbuf[..], Some(timeout)); match r { Err(Errno::EINTR) => continue, - Err(e) => panic!("aio_suspend returned {:?}", e), + Err(e) => panic!("aio_suspend returned {e:?}"), Ok(_) => (), }; } diff --git a/test/sys/test_signal.rs b/test/sys/test_signal.rs index 3ad14f40c7..721cb9c948 100644 --- a/test/sys/test_signal.rs +++ b/test/sys/test_signal.rs @@ -54,9 +54,8 @@ fn test_sigprocmask() { // test don't make sense. assert!( !old_signal_set.contains(SIGNAL), - "the {:?} signal is already blocked, please change to a \ - different one", - SIGNAL + "the {SIGNAL:?} signal is already blocked, please change to a \ + different one" ); // Now block the signal. @@ -71,8 +70,7 @@ fn test_sigprocmask() { .expect("expect to be able to retrieve old signals"); assert!( old_signal_set.contains(SIGNAL), - "expected the {:?} to be blocked", - SIGNAL + "expected the {SIGNAL:?} to be blocked" ); // Reset the signal. diff --git a/test/sys/test_socket.rs b/test/sys/test_socket.rs index 1413eb6b2e..2ab6c54f6e 100644 --- a/test/sys/test_socket.rs +++ b/test/sys/test_socket.rs @@ -626,7 +626,7 @@ mod recvfrom { println!("IPv6 not available, skipping test."); return; } - Err(e) => panic!("bind: {}", e), + Err(e) => panic!("bind: {e}"), Ok(()) => (), } let ssock = socket( @@ -1272,7 +1272,7 @@ fn test_scm_credentials() { ControlMessageOwned::ScmCredentials(cred) => cred, #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] ControlMessageOwned::ScmCreds(cred) => cred, - other => panic!("unexpected cmsg {:?}", other), + other => panic!("unexpected cmsg {other:?}"), }; assert!(received_cred.is_none()); assert_eq!(cred.pid(), getpid().as_raw()); @@ -1550,7 +1550,7 @@ fn loopback_address( Err(e) => { let stdioerr = io::stderr(); let mut handle = stdioerr.lock(); - writeln!(handle, "getifaddrs: {:?}", e).unwrap(); + writeln!(handle, "getifaddrs: {e:?}").unwrap(); return None; } }; @@ -2347,7 +2347,7 @@ mod linux_errqueue { } *ext_err } else { - panic!("Unexpected control message {:?}", cmsg); + panic!("Unexpected control message {cmsg:?}"); } }, ) @@ -2398,7 +2398,7 @@ mod linux_errqueue { } *ext_err } else { - panic!("Unexpected control message {:?}", cmsg); + panic!("Unexpected control message {cmsg:?}"); } }, ) @@ -2432,7 +2432,7 @@ mod linux_errqueue { MsgFlags::empty(), ) { assert_eq!(e, Errno::EADDRNOTAVAIL); - println!("{:?} not available, skipping test.", af); + println!("{af:?} not available, skipping test."); return; } diff --git a/test/test_fcntl.rs b/test/test_fcntl.rs index e51044a069..fb2a5e2ea0 100644 --- a/test/test_fcntl.rs +++ b/test/test_fcntl.rs @@ -559,7 +559,7 @@ mod test_posix_fallocate { let err = posix_fallocate(rd as RawFd, 0, 100).unwrap_err(); match err { Errno::EINVAL | Errno::ENODEV | Errno::ESPIPE | Errno::EBADF => (), - errno => panic!("unexpected errno {}", errno,), + errno => panic!("unexpected errno {errno}",), } } } diff --git a/test/test_mount.rs b/test/test_mount.rs index 2fd612e358..5cf00408e8 100644 --- a/test/test_mount.rs +++ b/test/test_mount.rs @@ -38,7 +38,7 @@ exit 23"; MsFlags::empty(), NONE, ) - .unwrap_or_else(|e| panic!("mount failed: {}", e)); + .unwrap_or_else(|e| panic!("mount failed: {e}")); let test_path = tempdir.path().join("test"); @@ -67,17 +67,17 @@ exit 23"; .unwrap(); process::exit(0); } else { - panic!("open failed: {}", e); + panic!("open failed: {e}"); } }) .and_then(|mut f| f.write(SCRIPT_CONTENTS)) - .unwrap_or_else(|e| panic!("write failed: {}", e)); + .unwrap_or_else(|e| panic!("write failed: {e}")); // Verify read. let mut buf = Vec::new(); File::open(&test_path) .and_then(|mut f| f.read_to_end(&mut buf)) - .unwrap_or_else(|e| panic!("read failed: {}", e)); + .unwrap_or_else(|e| panic!("read failed: {e}")); assert_eq!(buf, SCRIPT_CONTENTS); // Verify execute. @@ -85,13 +85,12 @@ exit 23"; EXPECTED_STATUS, Command::new(&test_path) .status() - .unwrap_or_else(|e| panic!("exec failed: {}", e)) + .unwrap_or_else(|e| panic!("exec failed: {e}")) .code() .unwrap_or_else(|| panic!("child killed by signal")) ); - umount(tempdir.path()) - .unwrap_or_else(|e| panic!("umount failed: {}", e)); + umount(tempdir.path()).unwrap_or_else(|e| panic!("umount failed: {e}")); } pub fn test_mount_rdonly_disallows_write() { @@ -104,7 +103,7 @@ exit 23"; MsFlags::MS_RDONLY, NONE, ) - .unwrap_or_else(|e| panic!("mount failed: {}", e)); + .unwrap_or_else(|e| panic!("mount failed: {e}")); // EROFS: Read-only file system assert_eq!( @@ -115,8 +114,7 @@ exit 23"; .unwrap() ); - umount(tempdir.path()) - .unwrap_or_else(|e| panic!("umount failed: {}", e)); + umount(tempdir.path()).unwrap_or_else(|e| panic!("umount failed: {e}")); } pub fn test_mount_noexec_disallows_exec() { @@ -129,7 +127,7 @@ exit 23"; MsFlags::MS_NOEXEC, NONE, ) - .unwrap_or_else(|e| panic!("mount failed: {}", e)); + .unwrap_or_else(|e| panic!("mount failed: {e}")); let test_path = tempdir.path().join("test"); @@ -139,13 +137,13 @@ exit 23"; .mode((Mode::S_IRWXU | Mode::S_IRWXG | Mode::S_IRWXO).bits()) .open(&test_path) .and_then(|mut f| f.write(SCRIPT_CONTENTS)) - .unwrap_or_else(|e| panic!("write failed: {}", e)); + .unwrap_or_else(|e| panic!("write failed: {e}")); // Verify that we cannot execute despite a+x permissions being set. let mode = stat::Mode::from_bits_truncate( fs::metadata(&test_path) .map(|md| md.permissions().mode()) - .unwrap_or_else(|e| panic!("metadata failed: {}", e)), + .unwrap_or_else(|e| panic!("metadata failed: {e}")), ); assert!( @@ -164,8 +162,7 @@ exit 23"; .unwrap() ); - umount(tempdir.path()) - .unwrap_or_else(|e| panic!("umount failed: {}", e)); + umount(tempdir.path()).unwrap_or_else(|e| panic!("umount failed: {e}")); } pub fn test_mount_bind() { @@ -182,7 +179,7 @@ exit 23"; MsFlags::MS_BIND, NONE, ) - .unwrap_or_else(|e| panic!("mount failed: {}", e)); + .unwrap_or_else(|e| panic!("mount failed: {e}")); fs::OpenOptions::new() .create(true) @@ -190,10 +187,10 @@ exit 23"; .mode((Mode::S_IRWXU | Mode::S_IRWXG | Mode::S_IRWXO).bits()) .open(mount_point.path().join(file_name)) .and_then(|mut f| f.write(SCRIPT_CONTENTS)) - .unwrap_or_else(|e| panic!("write failed: {}", e)); + .unwrap_or_else(|e| panic!("write failed: {e}")); umount(mount_point.path()) - .unwrap_or_else(|e| panic!("umount failed: {}", e)); + .unwrap_or_else(|e| panic!("umount failed: {e}")); } // Verify the file written in the mount shows up in source directory, even @@ -202,7 +199,7 @@ exit 23"; let mut buf = Vec::new(); File::open(tempdir.path().join(file_name)) .and_then(|mut f| f.read_to_end(&mut buf)) - .unwrap_or_else(|e| panic!("read failed: {}", e)); + .unwrap_or_else(|e| panic!("read failed: {e}")); assert_eq!(buf, SCRIPT_CONTENTS); } @@ -214,8 +211,7 @@ exit 23"; let stderr = io::stderr(); let mut handle = stderr.lock(); writeln!(handle, - "unshare failed: {}. Are unprivileged user namespaces available?", - e).unwrap(); + "unshare failed: {e}. Are unprivileged user namespaces available?").unwrap(); writeln!(handle, "mount is not being tested").unwrap(); // Exit with success because not all systems support unprivileged user namespaces, and // that's not what we're testing for. @@ -226,8 +222,8 @@ exit 23"; fs::OpenOptions::new() .write(true) .open("/proc/self/uid_map") - .and_then(|mut f| f.write(format!("1000 {} 1\n", uid).as_bytes())) - .unwrap_or_else(|e| panic!("could not write uid map: {}", e)); + .and_then(|mut f| f.write(format!("1000 {uid} 1\n").as_bytes())) + .unwrap_or_else(|e| panic!("could not write uid map: {e}")); } } diff --git a/test/test_unistd.rs b/test/test_unistd.rs index 9e20f977ec..6619262e93 100644 --- a/test/test_unistd.rs +++ b/test/test_unistd.rs @@ -56,11 +56,11 @@ fn test_fork_and_waitpid() { // panic, must never happen s @ Ok(_) => { - panic!("Child exited {:?}, should never happen", s) + panic!("Child exited {s:?}, should never happen") } // panic, waitpid should never fail - Err(s) => panic!("Error: waitpid returned Err({:?}", s), + Err(s) => panic!("Error: waitpid returned Err({s:?}"), } } } @@ -94,7 +94,7 @@ fn test_mkstemp() { close(fd).unwrap(); unlink(path.as_path()).unwrap(); } - Err(e) => panic!("mkstemp failed: {}", e), + Err(e) => panic!("mkstemp failed: {e}"), } } @@ -799,12 +799,7 @@ static mut ALARM_CALLED: bool = false; // Used in `test_alarm`. #[cfg(not(target_os = "redox"))] pub extern "C" fn alarm_signal_handler(raw_signal: libc::c_int) { - assert_eq!( - raw_signal, - libc::SIGALRM, - "unexpected signal: {}", - raw_signal - ); + assert_eq!(raw_signal, libc::SIGALRM, "unexpected signal: {raw_signal}"); unsafe { ALARM_CALLED = true }; }