The counter of a for loop is also changed in the body of the loop

tx0/c:loop-counter-assignedstrictwarningsmell

What it finds

for (i = 0; i < n; i++) { ... i += 2; ... }: a counter that the body changes as well as the head makes the number of steps hard to see; a while loop says it openly.

From the rule's source, loop_counter_assigned.rs.

Example from the rule's tests
void skip(int *a, int n){  int i;  for (i = 0; i < n; i++) {    if (a[i] == 0)      i++;tx0 reports: the loop counter i is changed in the body as well  }  for (i = 0; i < n; i++)    a[i] = 0;}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/c:loop-counter-assigned" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/c:loop-counter-assigned] reason="..."

tx0 explain tx0/c:loop-counter-assigned shows the same in the terminal. Found a false positive? Report it.