fix: bound timer counter to uint max on fail
This commit is contained in:
+2
-1
@@ -1,3 +1,4 @@
|
||||
#include <limits.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "types.h"
|
||||
@@ -12,7 +13,7 @@ void timer_init(Timer *timer, const unsigned int target) {
|
||||
|
||||
bool timer_inc(Timer *timer) {
|
||||
timer->counter += 1;
|
||||
return timer->counter >= timer->target;
|
||||
return timer->counter == UINT_MAX || timer->counter >= timer->target;
|
||||
}
|
||||
|
||||
double timer_reset(Timer *timer) {
|
||||
|
||||
Reference in New Issue
Block a user