Skip to content

Commit 45511fe

Browse files
henrikbrixandersenkartben
authored andcommitted
drivers: can: mcan: declare the loop condition variables inside the loops
Declare the loop condition variable inside the loops to limit their scope. Signed-off-by: Henrik Brix Andersen <[email protected]>
1 parent 364ec03 commit 45511fe

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

drivers/can/can_mcan.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,6 @@ static void can_mcan_state_change_handler(const struct device *dev)
457457
void *state_cb_data = data->common.state_change_cb_user_data;
458458
const struct can_mcan_callbacks *cbs = config->callbacks;
459459
can_tx_callback_t tx_cb;
460-
uint32_t tx_idx;
461460
struct can_bus_err_cnt err_cnt;
462461
enum can_state state;
463462
uint32_t cccr;
@@ -480,7 +479,7 @@ static void can_mcan_state_change_handler(const struct device *dev)
480479
}
481480

482481
/* Call all TX queue callbacks with -ENETUNREACH */
483-
for (tx_idx = 0U; tx_idx < cbs->num_tx; tx_idx++) {
482+
for (uint32_t tx_idx = 0U; tx_idx < cbs->num_tx; tx_idx++) {
484483
tx_cb = cbs->tx[tx_idx].function;
485484

486485
if (tx_cb != NULL) {
@@ -1075,11 +1074,10 @@ int can_mcan_add_rx_filter_std(const struct device *dev, can_rx_callback_t callb
10751074
};
10761075
int filter_id = -ENOSPC;
10771076
int err;
1078-
int i;
10791077

10801078
k_mutex_lock(&data->lock, K_FOREVER);
10811079

1082-
for (i = 0; i < cbs->num_std; i++) {
1080+
for (int i = 0; i < cbs->num_std; i++) {
10831081
if (cbs->std[i].function == NULL) {
10841082
filter_id = i;
10851083
break;
@@ -1127,11 +1125,10 @@ static int can_mcan_add_rx_filter_ext(const struct device *dev, can_rx_callback_
11271125
};
11281126
int filter_id = -ENOSPC;
11291127
int err;
1130-
int i;
11311128

11321129
k_mutex_lock(&data->lock, K_FOREVER);
11331130

1134-
for (i = 0; i < cbs->num_ext; i++) {
1131+
for (int i = 0; i < cbs->num_ext; i++) {
11351132
if (cbs->ext[i].function == NULL) {
11361133
filter_id = i;
11371134
break;

0 commit comments

Comments
 (0)