Skip to content

Commit

Permalink
fix: time wconversion errors (#842)
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland authored Dec 20, 2024
1 parent 8dc7d13 commit 631fc87
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/system/unix/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ unsigned long z_clock_elapsed_s(z_clock_t *instant) {
}

void z_clock_advance_us(z_clock_t *clock, unsigned long duration) {
clock->tv_sec += duration / 1000000;
clock->tv_nsec += (duration % 1000000) * 1000;
clock->tv_sec += (time_t)(duration / 1000000);
clock->tv_nsec += (long int)((duration % 1000000) * 1000);

if (clock->tv_nsec >= 1000000000) {
clock->tv_sec += 1;
Expand All @@ -221,16 +221,16 @@ void z_clock_advance_us(z_clock_t *clock, unsigned long duration) {
}

void z_clock_advance_ms(z_clock_t *clock, unsigned long duration) {
clock->tv_sec += duration / 1000;
clock->tv_nsec += (duration % 1000) * 1000000;
clock->tv_sec += (time_t)(duration / 1000);
clock->tv_nsec += (long int)((duration % 1000) * 1000000);

if (clock->tv_nsec >= 1000000000) {
clock->tv_sec += 1;
clock->tv_nsec -= 1000000000;
}
}

void z_clock_advance_s(z_clock_t *clock, unsigned long duration) { clock->tv_sec += duration; }
void z_clock_advance_s(z_clock_t *clock, unsigned long duration) { clock->tv_sec += (time_t)duration; }

/*------------------ Time ------------------*/
z_time_t z_time_now(void) {
Expand Down

0 comments on commit 631fc87

Please sign in to comment.