Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! npl/riot: Prevent overflow issues in time…
Browse files Browse the repository at this point in the history
…r glue
  • Loading branch information
bergzand committed Feb 13, 2020
1 parent 09b619b commit 7c6029b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions porting/npl/riot/include/nimble/nimble_npl_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ ble_npl_callout_set_arg(struct ble_npl_callout *co, void *arg)
co->e.arg = arg;
}

static inline uint32_t
static inline ble_npl_time_t
ble_npl_time_get(void)
{
return xtimer_now_usec64() / US_PER_MS;
return (ble_npl_time_t)(xtimer_now_usec64() / US_PER_MS);
}

static inline ble_npl_error_t
Expand Down
3 changes: 2 additions & 1 deletion porting/npl/riot/src/npl_os_riot.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ ble_npl_sem_pend(struct ble_npl_sem *sem, ble_npl_time_t timeout)
struct timespec abs;
uint64_t time;

time = xtimer_now_usec64() + ble_npl_time_ticks_to_ms32(timeout) * US_PER_MS;
time = xtimer_now_usec64() +
(ble_npl_time_ticks_to_ms32(timeout) * US_PER_MS);
abs.tv_sec = (time_t)(time / US_PER_SEC);
abs.tv_nsec = (long)((time % US_PER_SEC) * NS_PER_US);

Expand Down

0 comments on commit 7c6029b

Please sign in to comment.