Skip to content

Commit f352c28

Browse files
committed
Merge branch 'mc/use-ulong-max'
* mc/use-ulong-max: src:arduino-timer:ticks use ULONG_MAX
2 parents c1f3e42 + feefff5 commit f352c28

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/arduino-timer.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
#include <WProgram.h>
4242
#endif
4343

44+
#include <limits.h>
45+
4446
#ifndef TIMER_MAX_TASKS
4547
#define TIMER_MAX_TASKS 0x10
4648
#endif
@@ -142,7 +144,7 @@ class Timer {
142144
unsigned long
143145
ticks() const
144146
{
145-
unsigned long ticks = (unsigned long)-1, elapsed;
147+
unsigned long ticks = ULONG_MAX, elapsed;
146148
const unsigned long start = time_func();
147149

148150
timer_foreach_const_task(task) {
@@ -162,7 +164,7 @@ class Timer {
162164

163165
elapsed = time_func() - start;
164166

165-
if (elapsed >= ticks || ticks == (unsigned long)-1) ticks = 0;
167+
if (elapsed >= ticks || ticks == ULONG_MAX) ticks = 0;
166168
else ticks -= elapsed;
167169

168170
return ticks;

0 commit comments

Comments
 (0)