mirror of
https://github.com/linux-can/can-utils.git
synced 2026-08-05 06:20:00 +02:00
canfdtest: can_echo_gen(): use modulo instead of if to handle wrap arounds
This commit is contained in:
+4
-6
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user