]> sigrok.org Git - libsigrok.git/commitdiff
link-mso19: Rename variables to be more descriptive
authorPaul Kasemir <redacted>
Mon, 12 Dec 2022 19:00:18 +0000 (12:00 -0700)
committerSoeren Apel <redacted>
Wed, 16 Oct 2024 22:09:23 +0000 (00:09 +0200)
src/hardware/link-mso19/protocol.c
src/hardware/link-mso19/protocol.h

index 299e6f0012ce4fae7b29b62cbdc8cef3b433173b..3f5c99a7e26376def73d12ebe2279e1eb5952f41 100644 (file)
@@ -34,30 +34,33 @@ static const char mso_foot[] = { 0x7e };
 static int mso_send_control_message(struct sr_serial_dev_inst *serial,
                                    uint16_t payload[], int n)
 {
-       int w, ret;
-       int payload_s = n * sizeof(*payload);
-       int s = payload_s + sizeof(mso_head) + sizeof(mso_foot);
-       char *p, *buf;
+       int written, ret, payload_size, total_size;
+       char *copy_ptr, *buf;
 
+       payload_size = n * sizeof(*payload);
+       total_size = payload_size + sizeof(mso_head) + sizeof(mso_foot);
        ret = SR_ERR;
 
-       buf = g_malloc(s);
-
-       p = buf;
-       memcpy(p, mso_head, sizeof(mso_head));
-       p += sizeof(mso_head);
-       memcpy(p, payload, payload_s);
-       p += payload_s;
-       memcpy(p, mso_foot, sizeof(mso_foot));
-
-       w = 0;
-       while (w < s) {
-               ret = serial_write_blocking(serial, buf + w, s - w, 10);
+       buf = g_malloc(total_size);
+
+       copy_ptr = buf;
+       memcpy(copy_ptr, mso_head, sizeof(mso_head));
+       copy_ptr += sizeof(mso_head);
+       memcpy(copy_ptr, payload, payload_size);
+       copy_ptr += payload_size;
+       memcpy(copy_ptr, mso_foot, sizeof(mso_foot));
+
+       written = 0;
+       while (written < total_size) {
+               ret = serial_write_blocking(serial,
+                               buf + written,
+                               total_size - written,
+                               10);
                if (ret < 0) {
                        ret = SR_ERR;
                        goto free;
                }
-               w += ret;
+               written += ret;
        }
        ret = SR_OK;
 free:
@@ -173,23 +176,23 @@ SR_PRIV uint16_t mso_calc_trigger_threshold(struct dev_context *devc)
                            devc->vbit));
 }
 
-SR_PRIV int mso_parse_serial(const char *iSerial, const char *iProduct,
+SR_PRIV int mso_parse_serial(const char *serial_num, const char *product,
                             struct dev_context *devc)
 {
        unsigned int u1, u2, u3, u4, u5, u6;
 
-       (void)iProduct;
+       (void)product;
 
        /* FIXME: This code is in the original app, but I think its
         * used only for the GUI */
-       /*    if (strstr(iProduct, "REV_02") || strstr(iProduct, "REV_03"))
+       /*    if (strstr(product, "REV_02") || strstr(product, "REV_03"))
           devc->num_sample_rates = 0x16;
           else
           devc->num_sample_rates = 0x10; */
 
        /* parse iSerial */
-       if (iSerial[0] != '4' || sscanf(iSerial, "%5u%3u%3u%1u%1u%6u",
-                                       &u1, &u2, &u3, &u4, &u5, &u6) != 6)
+       if (serial_num[0] != '4' || sscanf(serial_num, "%5u%3u%3u%1u%1u%6u",
+                                          &u1, &u2, &u3, &u4, &u5, &u6) != 6)
                return SR_ERR;
        if (u1 == 0)
                u1 = 42874;
@@ -205,7 +208,7 @@ SR_PRIV int mso_parse_serial(const char *iSerial, const char *iProduct,
 
        /*
         * FIXME: There is more code on the original software to handle
-        * bigger iSerial strings, but as I can't test on my device
+        * bigger serial_num strings, but as I can't test on my device
         * I will not implement it yet
         */
 
index 56ec45f36730c740aadcc1392fff5d91aa049d5c..487d7d2cebdf521ca9c1648d97321e249c449f8a 100644 (file)
@@ -114,7 +114,7 @@ struct dev_context {
        char buffer[4096];
 };
 
-SR_PRIV int mso_parse_serial(const char *iSerial, const char *iProduct,
+SR_PRIV int mso_parse_serial(const char *serial_num, const char *product,
                             struct dev_context *ctx);
 SR_PRIV int mso_read_status(struct sr_serial_dev_inst *serial,
                            uint8_t *status);