]> sigrok.org Git - libsigrok.git/commitdiff
rdtech-tc: avoid mixing several iterations in the same for loop
authorGerhard Sittig <redacted>
Thu, 16 Mar 2023 02:31:12 +0000 (03:31 +0100)
committerGerhard Sittig <redacted>
Thu, 16 Mar 2023 13:29:30 +0000 (14:29 +0100)
Separate the iteration of a channels list, and indexing their associated
binary helpers descriptions. Use the for() statement for list iteration
exclusively, avoid the comma operator.

src/hardware/rdtech-tc/protocol.c

index 39d52ba5c3ea6935e127f6f48e68a1a992b79f67..e1cff006770813bfa9b4757c940ce545deebe5b3 100644 (file)
@@ -193,9 +193,11 @@ static void handle_poll_data(const struct sr_dev_inst *sdi)
                return;
        }
 
-       for (ch = sdi->channels, i = 0; ch; ch = g_slist_next(ch), i++) {
+       i = 0;
+       for (ch = sdi->channels; ch; ch = g_slist_next(ch)) {
                bv_send_analog_channel(sdi, ch->data,
                        &devc->channels[i], poll_pkt, TC_POLL_LEN);
+               i++;
        }
 
        sr_sw_limits_update_samples_read(&devc->limits, 1);