Skip to content

Commit f18c549

Browse files
Surya-Tummakartben
authored andcommitted
drivers: counter: shell: fix off-by-one check in periodic loop
Migrate the periodic loop to a standard for-loop to fix an off-by-one check in the periodic timer shell command. Signed-off-by: Surya Prakash T <suryat@aerlync.com>
1 parent acdfb06 commit f18c549

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/counter/counter_timer_shell.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,9 @@ static int cmd_timer_periodic(const struct shell *shctx, size_t argc, char **arg
210210

211211
/* Checking periodic interrupt for PERIODIC_CYCLES times and then unblocking shell.
212212
* Timer is still running and interrupt is triggered periodically.
213+
* Wait for the exact number of periodic cycles configured
213214
*/
214-
while (++count < PERIODIC_CYCLES) {
215+
for (count = 0; count < PERIODIC_CYCLES; count++) {
215216
k_sem_take(&timer_sem, K_FOREVER);
216217
}
217218

0 commit comments

Comments
 (0)