From 163d1241b3bdb5875c9235c0a539b7121fb60177 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Fri, 25 May 2018 07:03:22 -0700 Subject: [PATCH] timer_reset: do not do anything if the timer has not expired --- os/sys/timer.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/os/sys/timer.c b/os/sys/timer.c index 1eeae64de..b99aa4127 100644 --- a/os/sys/timer.c +++ b/os/sys/timer.c @@ -74,9 +74,8 @@ timer_set(struct timer *t, clock_time_t interval) * given to the timer_set() function. The start point of the interval * is the exact time that the timer last expired. Therefore, this * function will cause the timer to be stable over time, unlike the - * timer_restart() function. - * - * \note Must not be executed before timer expired + * timer_restart() function. If this is executed before the + * timer expired, this function has no effect. * * \param t A pointer to the timer. * \sa timer_restart() @@ -84,7 +83,9 @@ timer_set(struct timer *t, clock_time_t interval) void timer_reset(struct timer *t) { - t->start += t->interval; + if(timer_expired(t)) { + t->start += t->interval; + } } /*---------------------------------------------------------------------------*/ /**