Skip to content

Commit

Permalink
Avoid unnecessary #[cfg] in untyped_ioctl function (#58)
Browse files Browse the repository at this point in the history
It is not necessary since we can generically cast to the right value by
doing `ioctl as _`.
  • Loading branch information
Phantomical authored Nov 18, 2024
1 parent 875564c commit bc42e06
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions perf-event-open-sys/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,9 @@ pub mod ioctls {
}

unsafe fn untyped_ioctl<A>(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)
}
}

0 comments on commit bc42e06

Please sign in to comment.