]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/hantek-dso/api.c
Channel names consistency fixes and simplifications.
[libsigrok.git] / src / hardware / hantek-dso / api.c
index 253d37cdbe54bdb63d47ea7001a5928363dc8625..c990a5c53cbb6f1901a00003c2fe161739ba99de 100644 (file)
@@ -69,7 +69,6 @@ static const uint32_t devopts_cg[] = {
 
 static const char *channel_names[] = {
        "CH1", "CH2",
-       NULL,
 };
 
 static const uint64_t buffersizes_32k[] = {
@@ -169,7 +168,7 @@ static struct sr_dev_inst *dso_dev_new(const struct dso_profile *prof)
        struct sr_channel_group *cg;
        struct drv_context *drvc;
        struct dev_context *devc;
-       int i;
+       unsigned int i;
 
        sdi = g_malloc0(sizeof(struct sr_dev_inst));
        sdi->status = SR_ST_INITIALIZING;
@@ -181,7 +180,7 @@ static struct sr_dev_inst *dso_dev_new(const struct dso_profile *prof)
         * Add only the real channels -- EXT isn't a source of data, only
         * a trigger source internal to the device.
         */
-       for (i = 0; channel_names[i]; i++) {
+       for (i = 0; i < ARRAY_SIZE(channel_names); i++) {
                ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, channel_names[i]);
                cg = g_malloc0(sizeof(struct sr_channel_group));
                cg->name = g_strdup(channel_names[i]);
@@ -434,8 +433,6 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
        const uint64_t *vdiv;
        int ch_idx;
 
-       (void)cg;
-
        switch (key) {
        case SR_CONF_NUM_HDIV:
                *data = g_variant_new_int32(NUM_TIMEBASE);
@@ -492,7 +489,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
                        ch_idx = 1;
                else
                        return SR_ERR_ARG;
-               switch(key) {
+               switch (key) {
                case SR_CONF_FILTER:
                        *data = g_variant_new_boolean(devc->filter[ch_idx]);
                        break;
@@ -651,7 +648,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                return SR_ERR_ARG;
 
        if (!cg) {
-       switch (key) {
+               switch (key) {
                case SR_CONF_DEVICE_OPTIONS:
                        *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
                                        devopts, ARRAY_SIZE(devopts), sizeof(uint32_t));
@@ -685,7 +682,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                        return SR_ERR_NA;
                }
        } else {
-       switch (key) {
+               switch (key) {
                case SR_CONF_DEVICE_OPTIONS:
                        *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
                                        devopts_cg, ARRAY_SIZE(devopts_cg), sizeof(uint32_t));