Fix stm32 compiler `conversion` warnings
Fixes several warnings when building for stm32 related to conversions
that may change the sign or value of a result.
@@ -51,13 +51,13 @@ static void msleep(uint32_t delay)
static inline void sys_clock_gettime(struct timespec *t)
{
- t->tv_sec = system_millis / 1000;
- t->tv_nsec = (system_millis % 1000) * 1000000;
+ t->tv_sec = (time_t) system_millis / 1000;
+ t->tv_nsec = ((int32_t) system_millis % 1000) * 1000000;
}
static int32_t timespec_diff_to_ms(struct timespec *timespec1, struct timespec *timespec2)
{
- return (timespec1->tv_sec - timespec2->tv_sec) * 1000 + (timespec1->tv_nsec - timespec2->tv_nsec) / 1000000;
+ return (int32_t) ((timespec1->tv_sec - timespec2->tv_sec) * 1000 + (timespec1->tv_nsec - timespec2->tv_nsec) / 1000000);
}
void sys_init_platform(GlobalContext *glb)
