Skip to content

Commit dd88c99

Browse files
Fix-Pointxiaoxiang781216
authored andcommitted
timers/clkcnt: Fix the assertion if max_tick > CLOCK_MAX.
This commit fixed the assertion if max_tick > CLOCK_MAX when the clock_t is 32-bit. Signed-off-by: ouyangxiangzhen <[email protected]>
1 parent 575844a commit dd88c99

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/nuttx/timers/clkcnt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ clock_t clkcnt_max_tick(clkcnt_t max_count, uint32_t freq)
127127
{
128128
clkcnt_t cnt = max_count / freq * TICK_PER_SEC +
129129
max_count % freq * TICK_PER_SEC / freq;
130-
DEBUGASSERT(cnt <= CLOCK_MAX);
130+
cnt = cnt <= CLOCK_MAX ? cnt : CLOCK_MAX;
131131
return (clock_t)cnt;
132132
}
133133

0 commit comments

Comments
 (0)