Skip to content

Commit f3b5ca5

Browse files
committed
replace goto with conditional break
1 parent c457d37 commit f3b5ca5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ports/esp32s2/peripherals/timer.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,26 @@ void peripherals_timer_reset(void) {
4646
}
4747

4848
void peripherals_timer_init(const timer_config_t * config, timer_index_t * timer) {
49+
bool break_loop = false;
50+
4951
// get free timer
5052
for (uint8_t i = 0; i < 2; i++) {
5153
for (uint8_t j = 0; j < 2; j++) {
5254
if (timer_state[i][j] == TIMER_FREE) {
5355
timer->idx = (timer_idx_t)j;
5456
timer->group = (timer_group_t)i;
5557
timer_state[i][j] = TIMER_BUSY;
56-
goto init_timer;
58+
break_loop = true;
59+
break;
5760
} else if (i == 1 && j == 1) {
5861
timer->idx = TIMER_MAX;
5962
timer->group = TIMER_GROUP_MAX;
6063
return;
6164
}
6265
}
66+
if (break_loop) {break;}
6367
}
6468

65-
init_timer:
6669
// initialize timer module
6770
timer_init(timer->group, timer->idx, config);
6871
timer_set_counter_value(timer->group, timer->idx, 0);

0 commit comments

Comments
 (0)