From bc42e06378b0b893207d07c51f9cac80ee6670af Mon Sep 17 00:00:00 2001 From: Sean Lynch Date: Mon, 18 Nov 2024 01:06:06 -0800 Subject: [PATCH] Avoid unnecessary #[cfg] in untyped_ioctl function (#58) It is not necessary since we can generically cast to the right value by doing `ioctl as _`. --- perf-event-open-sys/src/functions.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/perf-event-open-sys/src/functions.rs b/perf-event-open-sys/src/functions.rs index 2af857e..6308097 100644 --- a/perf-event-open-sys/src/functions.rs +++ b/perf-event-open-sys/src/functions.rs @@ -97,10 +97,9 @@ pub mod ioctls { } unsafe fn untyped_ioctl(fd: c_int, ioctl: bindings::perf_event_ioctls, arg: A) -> c_int { - #[cfg(any(target_env = "musl", target_os = "android"))] - return libc::ioctl(fd, ioctl as c_int, arg); - - #[cfg(not(any(target_env = "musl", target_os = "android")))] - libc::ioctl(fd, ioctl as c_ulong, arg) + // Depending on the libc implementation this may cast to either + // - c_int (musl or android), or, + // - c_ulong (glibc) + libc::ioctl(fd, ioctl as _, arg) } }