mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 14:33:33 +08:00
Fix overflows in abstime_to_ts
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This commit is contained in:
committed by
Beat Küng
parent
52b16d062c
commit
966560edc0
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user