Fix `add_timespec` in other codes besides `red_test` (#794)

This commit is contained in:
Windsgo 2024-03-21 14:51:29 +08:00 committed by GitHub
parent 1817b8b4fe
commit d478bce787
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -250,7 +250,7 @@ void add_timespec(struct timespec *ts, int64 addtime)
sec = (addtime - nsec) / NSEC_PER_SEC;
ts->tv_sec += sec;
ts->tv_nsec += nsec;
if ( ts->tv_nsec > NSEC_PER_SEC )
if ( ts->tv_nsec >= NSEC_PER_SEC )
{
nsec = ts->tv_nsec % NSEC_PER_SEC;
ts->tv_sec += (ts->tv_nsec - nsec) / NSEC_PER_SEC;

View File

@ -250,7 +250,7 @@ void add_timespec(struct timespec *ts, int64 addtime)
sec = (addtime - nsec) / NSEC_PER_SEC;
ts->tv_sec += sec;
ts->tv_nsec += nsec;
if ( ts->tv_nsec > NSEC_PER_SEC )
if ( ts->tv_nsec >= NSEC_PER_SEC )
{
nsec = ts->tv_nsec % NSEC_PER_SEC;
ts->tv_sec += (ts->tv_nsec - nsec) / NSEC_PER_SEC;