]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/gmc-mh-1x-2x/api.c
Fix a few "value never read" scan-build warnings.
[libsigrok.git] / src / hardware / gmc-mh-1x-2x / api.c
index 69b26794156f4988fd279bc8adc81173ebefa4b0..85077df4f9555c9a0f6ee89e81727091341ea503 100644 (file)
@@ -22,6 +22,7 @@
  *  @internal
  */
 
+#include <config.h>
 #include <string.h>
 #include "protocol.h"
 
@@ -108,7 +109,7 @@ static enum model scan_model_sm(struct sr_serial_dev_inst *serial)
        gint64 timeout_us;
 
        model = METRAHIT_NONE;
-       timeout_us = g_get_monotonic_time() + 1 * 1000 * 1000;
+       timeout_us = g_get_monotonic_time() + (1 * 1000 * 1000);
 
        /*
         * Try to find message consisting of device code and several
@@ -161,10 +162,9 @@ static GSList *scan_1x_2x_rs232(struct sr_dev_driver *di, GSList *options)
        gboolean serialcomm_given;
 
        devices = NULL;
-       drvc = di->priv;
+       drvc = di->context;
        drvc->instances = NULL;
        conn = serialcomm = NULL;
-       model = METRAHIT_NONE;
        serialcomm_given = FALSE;
 
        sr_spew("scan_1x_2x_rs232() called!");
@@ -256,7 +256,7 @@ static GSList *scan_2x_bd232(struct sr_dev_driver *di, GSList *options)
        conn = serialcomm = NULL;
        devices = NULL;
 
-       drvc = di->priv;
+       drvc = di->context;
        drvc->instances = NULL;
 
        sr_spew("scan_2x_bd232() called!");
@@ -296,18 +296,18 @@ static GSList *scan_2x_bd232(struct sr_dev_driver *di, GSList *options)
                goto exit_err;
 
        /* Wait for reply from device(s) for up to 2s. */
-       timeout_us = g_get_monotonic_time() + 2*1000*1000;
+       timeout_us = g_get_monotonic_time() + (2 * 1000 * 1000);
 
        while (timeout_us > g_get_monotonic_time()) {
                /* Receive reply (14 bytes) */
                devc->buflen = 0;
-               for (cnt = 0; cnt < 14; cnt++) {
+               for (cnt = 0; cnt < GMC_REPLY_SIZE; cnt++) {
                        byte = read_byte(serial, timeout_us);
                        if (byte != -1)
                                devc->buf[devc->buflen++] = (byte & MASK_6BITS);
                }
 
-               if (devc->buflen != 14)
+               if (devc->buflen != GMC_REPLY_SIZE)
                        continue;
 
                devc->addr = devc->buf[0];
@@ -345,8 +345,7 @@ exit_err:
 
        if (serial)
                sr_serial_dev_inst_free(serial);
-       if (devc)
-               g_free(devc);
+       g_free(devc);
        if (sdi)
                sr_dev_inst_free(sdi);
 
@@ -355,7 +354,7 @@ exit_err:
 
 static GSList *dev_list(const struct sr_dev_driver *di)
 {
-       return ((struct drv_context *)(di->priv))->instances;
+       return ((struct drv_context *)(di->context))->instances;
 }
 
 static int dev_close(struct sr_dev_inst *sdi)
@@ -389,8 +388,6 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
 
        (void)cg;
 
-       ret = SR_OK;
-
        if (!sdi || !(devc = sdi->priv))
                return SR_ERR_ARG;
 
@@ -554,7 +551,7 @@ SR_PRIV struct sr_dev_driver gmc_mh_1x_2x_rs232_driver_info = {
        .dev_close = dev_close,
        .dev_acquisition_start = dev_acquisition_start_1x_2x_rs232,
        .dev_acquisition_stop = dev_acquisition_stop,
-       .priv = NULL,
+       .context = NULL,
 };
 
 SR_PRIV struct sr_dev_driver gmc_mh_2x_bd232_driver_info = {
@@ -573,5 +570,5 @@ SR_PRIV struct sr_dev_driver gmc_mh_2x_bd232_driver_info = {
        .dev_close = dev_close,
        .dev_acquisition_start = dev_acquisition_start_2x_bd232,
        .dev_acquisition_stop = dev_acquisition_stop,
-       .priv = NULL,
+       .context = NULL,
 };