From 7f7d0f18757836180feaa2f6627e9c2e53878be9 Mon Sep 17 00:00:00 2001 From: Michael Tokarev Date: Sun, 16 Apr 2023 15:16:32 +0300 Subject: [PATCH] linux/timerfd: stop explicitly casting to c_long for timespec.tv_nsec struct timespec.tv_nsec is implementation-specific (even if the doc says it is c_long). For example, on x32 it is i64. Do not explicitly cast nsec value to c_long, use whatever type needed for the target type. Signed-off-by: Michael Tokarev --- src/linux/timerfd.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/linux/timerfd.rs b/src/linux/timerfd.rs index 80f0789..efa952c 100644 --- a/src/linux/timerfd.rs +++ b/src/linux/timerfd.rs @@ -71,9 +71,7 @@ impl TimerFd { { spec.it_value.tv_sec = dur.as_secs() as libc::time_t; } - // nsec always fits in i32 because subsec_nanos is defined to be less than one billion. - let nsec = dur.subsec_nanos() as i32; - spec.it_value.tv_nsec = libc::c_long::from(nsec); + spec.it_value.tv_nsec = dur.subsec_nanos() as _; if let Some(int) = interval { // https://github.com/rust-lang/libc/issues/1848 @@ -81,9 +79,7 @@ impl TimerFd { { spec.it_interval.tv_sec = int.as_secs() as libc::time_t; } - // nsec always fits in i32 because subsec_nanos is defined to be less than one billion. - let nsec = int.subsec_nanos() as i32; - spec.it_interval.tv_nsec = libc::c_long::from(nsec); + spec.it_interval.tv_nsec = int.subsec_nanos() as _; } // SAFETY: Safe because this doesn't modify any memory and we check the return value.