diff options
author | Simon Ser <contact@emersion.fr> | 2022-11-23 15:56:37 +0100 |
---|---|---|
committer | Simon Zeni <simon@bl4ckb0ne.ca> | 2022-11-25 16:15:29 +0000 |
commit | 769cabbadf295fbe26cd2c3eb6efd5233c4d14e8 (patch) | |
tree | 4738bca913f958c615b84bf34de552211199609d | |
parent | fb4fb3bac2c7a73baf773cc6a0bba486f1c227b4 (diff) |
util/time: use int64_t return value for get_current_time_msec()
0xFFFFFFFF milliseconds is 4,294,967,295 ms so about 50 days.
A little bit too close for comfort.
Use int64_t instead of uint64_t to avoid C's implicit conversion
footguns in computations.
-rw-r--r-- | include/util/time.h | 2 | ||||
-rw-r--r-- | util/time.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/include/util/time.h b/include/util/time.h index 287698de..890fe55f 100644 --- a/include/util/time.h +++ b/include/util/time.h @@ -6,7 +6,7 @@ /** * Get the current time, in milliseconds. */ -uint32_t get_current_time_msec(void); +int64_t get_current_time_msec(void); /** * Convert a timespec to milliseconds. diff --git a/util/time.c b/util/time.c index 06e42b40..c561d23a 100644 --- a/util/time.c +++ b/util/time.c @@ -15,7 +15,7 @@ void timespec_from_nsec(struct timespec *r, int64_t nsec) { r->tv_nsec = nsec % NSEC_PER_SEC; } -uint32_t get_current_time_msec(void) { +int64_t get_current_time_msec(void) { struct timespec now; clock_gettime(CLOCK_MONOTONIC, &now); return timespec_to_msec(&now); |