]> sigrok.org Git - libsigrok.git/commitdiff
rdtech-tc: rename "buflen" variable, it's "read length"
authorGerhard Sittig <redacted>
Sun, 19 Mar 2023 14:35:33 +0000 (15:35 +0100)
committerGerhard Sittig <redacted>
Sun, 19 Mar 2023 21:40:08 +0000 (22:40 +0100)
The 'buflen' variable name could be misleading, as it's not the receive
buffer's size. Instead it is the amount of previously received response
data. Rename it to 'rdlen'.

src/hardware/rdtech-tc/protocol.c
src/hardware/rdtech-tc/protocol.h

index fd392884735885c4fc1ffa90d1cd250d2071c3c8..ef1cd34bf817462f647f9c2cc9ff634bea5d9f52 100644 (file)
@@ -167,7 +167,7 @@ SR_PRIV int rdtech_tc_poll(const struct sr_dev_inst *sdi, gboolean force)
         * Don't send the request while receive data is being accumulated.
         */
        devc = sdi->priv;
-       if (!force && devc->buflen)
+       if (!force && devc->rdlen)
                return SR_OK;
 
        /*
@@ -205,9 +205,9 @@ static int handle_poll_data(struct sr_dev_inst *sdi)
        float v;
 
        devc = sdi->priv;
-       sr_spew("Received poll packet (len: %zu).", devc->buflen);
-       if (devc->buflen < TC_POLL_LEN) {
-               sr_err("Insufficient poll packet length: %zu", devc->buflen);
+       sr_spew("Received poll packet (len: %zu).", devc->rdlen);
+       if (devc->rdlen < TC_POLL_LEN) {
+               sr_err("Insufficient poll packet length: %zu", devc->rdlen);
                return SR_ERR_DATA;
        }
 
@@ -245,15 +245,15 @@ static int recv_poll_data(struct sr_dev_inst *sdi, struct sr_serial_dev_inst *se
 
        /* Receive data became available. Drain the transport layer. */
        devc = sdi->priv;
-       while (devc->buflen < TC_POLL_LEN) {
-               space = sizeof(devc->buf) - devc->buflen;
+       while (devc->rdlen < TC_POLL_LEN) {
+               space = sizeof(devc->buf) - devc->rdlen;
                len = serial_read_nonblocking(serial,
-                       &devc->buf[devc->buflen], space);
+                       &devc->buf[devc->rdlen], space);
                if (len < 0)
                        return SR_ERR_IO;
                if (len == 0)
                        return SR_OK;
-               devc->buflen += len;
+               devc->rdlen += len;
        }
 
        /*
@@ -262,13 +262,13 @@ static int recv_poll_data(struct sr_dev_inst *sdi, struct sr_serial_dev_inst *se
         */
 
        /* Process packets when their reception has completed. */
-       while (devc->buflen >= TC_POLL_LEN) {
+       while (devc->rdlen >= TC_POLL_LEN) {
                ret = handle_poll_data(sdi);
                if (ret != SR_OK)
                        return ret;
-               devc->buflen -= TC_POLL_LEN;
-               if (devc->buflen)
-                       memmove(&devc->buf[0], &devc->buf[TC_POLL_LEN], devc->buflen);
+               devc->rdlen -= TC_POLL_LEN;
+               if (devc->rdlen)
+                       memmove(devc->buf, &devc->buf[TC_POLL_LEN], devc->rdlen);
        }
 
        return SR_OK;
index 6458460ad49c1dcac61a539a81a9c3764460cbb8..fb0259067858a7a9600a07d254713306b3da88f5 100644 (file)
@@ -49,7 +49,7 @@ struct dev_context {
        struct feed_queue_analog **feeds;
        struct sr_sw_limits limits;
        uint8_t buf[RDTECH_TC_BUFSIZE];
-       size_t buflen;
+       size_t rdlen;
        int64_t cmd_sent_at;
 };