canfdtest: can_echo_gen(): use modulo instead of if to handle wrap arounds

pull/488/head
Marc Kleine-Budde 2023-12-19 15:02:02 +01:00
parent 7bb00837d0
commit f110bf4cde
1 changed files with 4 additions and 6 deletions

View File

@ -346,8 +346,8 @@ static int can_echo_gen(void)
} }
send_pos++; send_pos++;
if (send_pos == inflight_count) send_pos %= inflight_count;
send_pos = 0;
unprocessed++; unprocessed++;
if (verbose == 1) if (verbose == 1)
echo_progress(counter); echo_progress(counter);
@ -373,8 +373,7 @@ static int can_echo_gen(void)
err = compare_frame(&tx_frames[recv_tx_pos], &rx_frame, 0); err = compare_frame(&tx_frames[recv_tx_pos], &rx_frame, 0);
recv_tx[recv_tx_pos] = true; recv_tx[recv_tx_pos] = true;
recv_tx_pos++; recv_tx_pos++;
if (recv_tx_pos == inflight_count) recv_tx_pos %= inflight_count;
recv_tx_pos = 0;
continue; continue;
} }
@ -386,8 +385,7 @@ static int can_echo_gen(void)
/* compare with expected */ /* compare with expected */
err = compare_frame(&tx_frames[recv_rx_pos], &rx_frame, 1); err = compare_frame(&tx_frames[recv_rx_pos], &rx_frame, 1);
recv_rx_pos++; recv_rx_pos++;
if (recv_rx_pos == inflight_count) recv_rx_pos %= inflight_count;
recv_rx_pos = 0;
loops++; loops++;
if (test_loops && loops >= test_loops) if (test_loops && loops >= test_loops)