]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/scpi-pps/api.c
Fix a few "value never read" scan-build warnings.
[libsigrok.git] / src / hardware / scpi-pps / api.c
index 58e14f6e08abdaf9cf8848efad9fc0a0a6611401..25bc7eed773424bd2f6ce2ef64e14530906bb54a 100644 (file)
@@ -17,6 +17,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <config.h>
 #include <string.h>
 #include <strings.h>
 #include "scpi.h"
@@ -74,7 +75,7 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
        device = NULL;
        for (i = 0; i < num_pps_profiles; i++) {
                vendor = sr_vendor_alias(hw_info->manufacturer);
-               if (strcasecmp(vendor, pps_profiles[i].vendor))
+               if (g_ascii_strcasecmp(vendor, pps_profiles[i].vendor))
                        continue;
                model_re = g_regex_new(pps_profiles[i].model, 0, 0, NULL);
                if (g_regex_match(model_re, hw_info->model, 0, &model_mi))
@@ -261,7 +262,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
        const GVariantType *gvtype;
        unsigned int i;
        int cmd, ret;
-       char *s;
+       const char *s;
 
        if (!sdi)
                return SR_ERR_ARG;
@@ -364,19 +365,20 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
                 * return VOLT/CURR. We always return a GVariant string in
                 * the Rigol notation.
                 */
-               if ((ret = sr_scpi_get_string(sdi->conn, NULL, &s)) != SR_OK)
-                       return ret;
-               if (!strcmp(s, "CV") || !strcmp(s, "VOLT")) {
+               s = g_variant_get_string(*data, NULL);
+               if (!strcmp(s, "VOLT")) {
+                       g_variant_unref(*data);
                        *data = g_variant_new_string("CV");
-               } else if (!strcmp(s, "CC") || !strcmp(s, "CURR")) {
+               } else if (!strcmp(s, "CURR")) {
+                       g_variant_unref(*data);
                        *data = g_variant_new_string("CC");
-               } else if (!strcmp(s, "UR")) {
-                       *data = g_variant_new_string("UR");
-               } else {
+               }
+
+               s = g_variant_get_string(*data, NULL);
+               if (strcmp(s, "CV") && strcmp(s, "CC") && strcmp(s, "UR")) {
                        sr_dbg("Unknown response to SCPI_CMD_GET_OUTPUT_REGULATION: %s", s);
                        ret = SR_ERR_DATA;
                }
-               g_free(s);
        }
 
        return ret;
@@ -400,7 +402,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                select_channel(sdi, cg->channels->data);
 
        devc = sdi->priv;
-       ret = SR_OK;
+
        switch (key) {
        case SR_CONF_ENABLED:
                if (g_variant_get_boolean(data))
@@ -597,7 +599,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
        std_session_send_df_header(sdi, LOG_PREFIX);
 
        /* Prime the pipe with the first channel's fetch. */
-       ch = next_enabled_channel(sdi, NULL);
+       ch = sr_next_enabled_channel(sdi, NULL);
        pch = ch->priv;
        if ((ret = select_channel(sdi, ch)) < 0)
                return ret;