From 966560edc097ba7654afc459f854a2ebfaaadb7a Mon Sep 17 00:00:00 2001 From: Jukka Laitinen Date: Thu, 17 Nov 2022 11:44:53 +0400 Subject: [PATCH] Fix overflows in abstime_to_ts Signed-off-by: Jukka Laitinen --- src/drivers/drv_hrt.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/drivers/drv_hrt.h b/src/drivers/drv_hrt.h index bf701cbbd1..17563002c4 100644 --- a/src/drivers/drv_hrt.h +++ b/src/drivers/drv_hrt.h @@ -149,8 +149,8 @@ static inline hrt_abstime ts_to_abstime(const struct timespec *ts) */ static inline void abstime_to_ts(struct timespec *ts, hrt_abstime abstime) { - ts->tv_sec = (time_t)abstime / 1000000; - abstime -= (hrt_abstime)(ts->tv_sec * 1000000); + ts->tv_sec = (typeof(ts->tv_sec))(abstime / 1000000); + abstime -= (hrt_abstime)(ts->tv_sec) * 1000000; ts->tv_nsec = (typeof(ts->tv_nsec))(abstime * 1000); }