Fix overflows in abstime_to_ts

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This commit is contained in:
Jukka Laitinen
2022-11-18 07:10:05 +01:00
committed by Beat Küng
parent 52b16d062c
commit 966560edc0
+2 -2
View File
@@ -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);
}