]> sigrok.org Git - libsigrok.git/blobdiff - src/device.c
Fix sr_dev_has_option().
[libsigrok.git] / src / device.c
index 434d1066aac692d7a8a6f732f80938cc02f7ff02..9ed6080294096fabc7751903a096f7d1ae1457b3 100644 (file)
@@ -191,7 +191,7 @@ SR_API gboolean sr_dev_has_option(const struct sr_dev_inst *sdi, int key)
        ret = FALSE;
        devopts = g_variant_get_fixed_array(gvar, &num_opts, sizeof(int32_t));
        for (i = 0; i < num_opts; i++) {
-               if (devopts[i] == key) {
+               if ((devopts[i] & SR_CONF_MASK) == key) {
                        ret = TRUE;
                        break;
                }
@@ -213,7 +213,7 @@ SR_API gboolean sr_dev_has_option(const struct sr_dev_inst *sdi, int key)
  *  @retval struct sr_dev_inst *. Dynamically allocated, free using
  *              sr_dev_inst_free().
  */
-SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int index, int status,
+SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int status,
                const char *vendor, const char *model, const char *version)
 {
        struct sr_dev_inst *sdi;
@@ -224,12 +224,13 @@ SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int index, int status,
        }
 
        sdi->driver = NULL;
-       sdi->index = index;
        sdi->status = status;
        sdi->inst_type = -1;
        sdi->vendor = vendor ? g_strdup(vendor) : NULL;
        sdi->model = model ? g_strdup(model) : NULL;
        sdi->version = version ? g_strdup(version) : NULL;
+       sdi->serial_num = NULL;
+       sdi->connection_id = NULL;
        sdi->channels = NULL;
        sdi->channel_groups = NULL;
        sdi->session = NULL;
@@ -251,6 +252,7 @@ SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi)
        for (l = sdi->channels; l; l = l->next) {
                ch = l->data;
                g_free(ch->name);
+               g_free(ch->priv);
                g_free(ch);
        }
        g_slist_free(sdi->channels);
@@ -261,6 +263,8 @@ SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi)
        g_free(sdi->vendor);
        g_free(sdi->model);
        g_free(sdi->version);
+       g_free(sdi->serial_num);
+       g_free(sdi->connection_id);
        g_free(sdi);
 }