normalize_timespec: handle tv_nsec == 1000000000 correctly

This commit is contained in:
Oliver Jowett 2020-11-17 19:59:47 +08:00
parent e48006311b
commit 5c043e8496
1 changed files with 1 additions and 1 deletions

2
util.c
View File

@ -80,7 +80,7 @@ int64_t receiveclock_ms_elapsed(uint64_t t1, uint64_t t2)
void normalize_timespec(struct timespec *ts)
{
if (ts->tv_nsec > 1000000000) {
if (ts->tv_nsec >= 1000000000) {
ts->tv_sec += ts->tv_nsec / 1000000000;
ts->tv_nsec = ts->tv_nsec % 1000000000;
} else if (ts->tv_nsec < 0) {