]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/victor-dmm/api.c
hwdriver.c: Fix two scan-build warnings.
[libsigrok.git] / src / hardware / victor-dmm / api.c
index 55b90c7ef2e390c085a7cfa5082b4b1d5a2de7eb..d415a3f9cc86c4809db8dd44898a1c222dec3d19 100644 (file)
@@ -69,7 +69,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                if (des.idVendor != VICTOR_VID || des.idProduct != VICTOR_PID)
                        continue;
 
-               usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
+               if (usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)) < 0)
+                       continue;
 
                sdi = g_malloc0(sizeof(struct sr_dev_inst));
                sdi->status = SR_ST_INACTIVE;
@@ -137,12 +138,11 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
-               const struct sr_channel_group *cg)
+static int config_get(uint32_t key, GVariant **data,
+       const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
        struct dev_context *devc = sdi->priv;
        struct sr_usb_dev_inst *usb;
-       char str[128];
 
        (void)cg;
 
@@ -151,8 +151,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
                if (!sdi || !sdi->conn)
                        return SR_ERR_ARG;
                usb = sdi->conn;
-               snprintf(str, 128, "%d.%d", usb->bus, usb->address);
-               *data = g_variant_new_string(str);
+               *data = g_variant_new_printf("%d.%d", usb->bus, usb->address);
                break;
        case SR_CONF_LIMIT_SAMPLES:
        case SR_CONF_LIMIT_MSEC:
@@ -164,8 +163,8 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
        return SR_OK;
 }
 
-static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
-               const struct sr_channel_group *cg)
+static int config_set(uint32_t key, GVariant *data,
+       const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
        struct dev_context *devc;
 
@@ -176,8 +175,8 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
        return sr_sw_limits_config_set(&devc->limits, key, data);
 }
 
-static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
-               const struct sr_channel_group *cg)
+static int config_list(uint32_t key, GVariant **data,
+       const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
        return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
 }