sched/clock/clock_timekeeping.c: fix cases in time conversion that must be >= NSEC_PER_SEC, not >NSEC_PER_SEC. Similar to fix of f9e80c4a1e.

This commit is contained in:
Gregory Nutt
2019-08-27 18:18:10 -06:00
parent 5f02b0335f
commit b912c6fbff
+8 -8
View File
@@ -99,10 +99,10 @@ static int clock_get_current_time(FAR struct timespec *ts,
nsec -= sec * NSEC_PER_SEC;
nsec += base->tv_nsec;
if (nsec > NSEC_PER_SEC)
if (nsec >= NSEC_PER_SEC)
{
nsec -= NSEC_PER_SEC;
sec += 1;
sec += 1;
}
ts->tv_nsec = nsec;
@@ -153,7 +153,7 @@ errout_in_critical_section:
return ret;
}
/********************************************************************************
/****************************************************************************
* Name: adjtime
*
* Description:
@@ -248,10 +248,10 @@ void clock_update_wall_time(void)
nsec -= sec * NSEC_PER_SEC;
nsec += g_clock_wall_time.tv_nsec;
if (nsec > NSEC_PER_SEC)
if (nsec >= NSEC_PER_SEC)
{
nsec -= NSEC_PER_SEC;
sec += 1;
sec += 1;
}
if (g_clock_adjust != 0 && sec > 0)
@@ -267,13 +267,13 @@ void clock_update_wall_time(void)
while (nsec < 0)
{
nsec += NSEC_PER_SEC;
sec -= 1;
sec -= 1;
}
while (nsec > NSEC_PER_SEC)
while (nsec >= NSEC_PER_SEC)
{
nsec -= NSEC_PER_SEC;
sec += 1;
sec += 1;
}
}