]> sigrok.org Git - libsigrok.git/commitdiff
drivers: Remove some uneeded 'ret' variables.
authorUwe Hermann <redacted>
Wed, 12 Jul 2017 20:03:37 +0000 (22:03 +0200)
committerUwe Hermann <redacted>
Thu, 13 Jul 2017 09:59:11 +0000 (11:59 +0200)
21 files changed:
src/hardware/arachnid-labs-re-load-pro/api.c
src/hardware/atten-pps3xxx/api.c
src/hardware/baylibre-acme/api.c
src/hardware/beaglelogic/api.c
src/hardware/cem-dt-885x/api.c
src/hardware/conrad-digi-35-cpu/api.c
src/hardware/demo/api.c
src/hardware/ftdi-la/api.c
src/hardware/gmc-mh-1x-2x/api.c
src/hardware/hantek-6xxx/api.c
src/hardware/hantek-dso/api.c
src/hardware/hp-3457a/api.c
src/hardware/hung-chang-dso-2100/api.c
src/hardware/ikalogic-scanalogic2/api.c
src/hardware/kecheng-kc-330b/api.c
src/hardware/lecroy-xstream/api.c
src/hardware/link-mso19/api.c
src/hardware/maynuo-m97/api.c
src/hardware/saleae-logic-pro/api.c
src/hardware/saleae-logic16/api.c
src/hardware/scpi-pps/api.c

index 4fcd7b8541a1904df1dc90db45decba5b7386a86..bfbdd7d477a54bd4da7daf6db7ca04192fa506a6 100644 (file)
@@ -151,7 +151,6 @@ static int config_list(uint32_t key, GVariant **data,
        const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
        GVariantBuilder gvb;
-       int ret;
 
        /* Always available. */
        if (key == SR_CONF_SCAN_OPTIONS) {
@@ -169,8 +168,6 @@ static int config_list(uint32_t key, GVariant **data,
        if (!sdi)
                return SR_ERR_ARG;
 
-       ret = SR_OK;
-
        if (!cg) {
                /* No channel group: global options. */
                switch (key) {
@@ -200,14 +197,13 @@ static int config_list(uint32_t key, GVariant **data,
                }
        }
 
-       return ret;
+       return SR_OK;
 }
 
 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;
-       int ret;
        float fvalue;
 
        (void)cg;
@@ -223,7 +219,6 @@ static int config_get(uint32_t key, GVariant **data,
         *  - SR_CONF_ENABLED (state cannot be queried, only set)
         */
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_LIMIT_SAMPLES:
        case SR_CONF_LIMIT_MSEC:
@@ -267,7 +262,7 @@ static int config_get(uint32_t key, GVariant **data,
                return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_set(uint32_t key, GVariant *data,
index a90ab6ff68f80140ba6247fc50fec87b3aed36f0..a685c89c6d53fca8069ad7b9bcefe596703b43f7 100644 (file)
@@ -187,14 +187,13 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
 {
        struct dev_context *devc;
        struct sr_channel *ch;
-       int channel, ret;
+       int channel;
 
        if (!sdi)
                return SR_ERR_ARG;
 
        devc = sdi->priv;
 
-       ret = SR_OK;
        if (!cg) {
                /* No channel group: global options. */
                switch (key) {
@@ -233,7 +232,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
                }
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int find_str(const char *str, const char **strings, int array_size)
@@ -338,7 +337,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
        struct sr_channel *ch;
        GVariant *gvar;
        GVariantBuilder gvb;
-       int channel, ret, i;
+       int channel, i;
 
        /* Always available. */
        if (key == SR_CONF_SCAN_OPTIONS) {
@@ -357,7 +356,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                return SR_ERR_ARG;
 
        devc = sdi->priv;
-       ret = SR_OK;
+
        if (!cg) {
                /* No channel group: global options. */
                switch (key) {
@@ -413,7 +412,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                }
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int dev_close(struct sr_dev_inst *sdi)
index 73538583156e4909a7acb9b5593f089ef5f5e0a5..c467991de3d993294c419f9151fa7dc72bd25cd7 100644 (file)
@@ -217,12 +217,11 @@ static int config_list(uint32_t key, GVariant **data,
        uint32_t devopts_cg[MAX_DEVOPTS_CG];
        GVariant *gvar;
        GVariantBuilder gvb;
-       int ret, num_devopts_cg = 0;
+       int num_devopts_cg = 0;
 
        (void)sdi;
        (void)cg;
 
-       ret = SR_OK;
        if (!cg) {
                switch (key) {
                case SR_CONF_DEVICE_OPTIONS:
@@ -256,7 +255,7 @@ static int config_list(uint32_t key, GVariant **data,
                }
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static void dev_acquisition_close(const struct sr_dev_inst *sdi)
index 2b11fdc7d12eb501a4f491f6f85faa76d048b11b..64eb2c9268fc1811ff8b9c94fa8ea69974de45e6 100644 (file)
@@ -242,14 +242,12 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
 static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
-       int ret;
        GVariant *gvar;
        GVariantBuilder gvb;
 
        (void)sdi;
        (void)cg;
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_SCAN_OPTIONS:
                *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
@@ -275,7 +273,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 /* get a sane timeout for poll() */
index 98db1072cd465e37d86c97e8cda422bfe96d644c..33dd5c754c66c82cd78caa70eb0ec547bfb06ec2 100644 (file)
@@ -287,11 +287,9 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
        GVariant *tuple, *range[2];
        GVariantBuilder gvb;
        unsigned int i;
-       int ret;
 
        (void)cg;
 
-       ret = SR_OK;
        if (!sdi) {
                switch (key) {
                case SR_CONF_SCAN_OPTIONS:
@@ -335,7 +333,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                }
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int dev_acquisition_start(const struct sr_dev_inst *sdi)
index ba84f476a77f4334ff24231595270d771a6eb6b9..60eb46c1932ec1402c36c9a1fceebd7e4e5eee70 100644 (file)
@@ -136,12 +136,9 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
 static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
-       int ret;
-
        (void)sdi;
        (void)cg;
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_SCAN_OPTIONS:
                *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
@@ -155,7 +152,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static struct sr_dev_driver conrad_digi_35_cpu_driver_info = {
index f88b4c2ea794de37992a0e0fafb4a4a4bfee367f..4d95ddda3f13776ee30973445ed6e3e95d8fc521 100644 (file)
@@ -264,13 +264,12 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
        struct analog_gen *ag;
        struct sr_channel *ch;
        GSList *l;
-       int logic_pattern, analog_pattern, ret;
+       int logic_pattern, analog_pattern;
        unsigned int i;
        const char *stropt;
 
        devc = sdi->priv;
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_SAMPLERATE:
                devc->cur_samplerate = g_variant_get_uint64(data);
@@ -346,10 +345,10 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                }
                break;
        default:
-               ret = SR_ERR_NA;
+               return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
index 6eb2353d932b3d41a5ad6ec0a9f05aacd9593bda..27415ae3ec0389a08994497632cbaf6a7f516cb9 100644 (file)
@@ -323,7 +323,6 @@ static int dev_close(struct sr_dev_inst *sdi)
 static int config_get(uint32_t key, GVariant **data,
        const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
-       int ret;
        struct dev_context *devc;
        struct sr_usb_dev_inst *usb;
        char str[128];
@@ -332,7 +331,6 @@ static int config_get(uint32_t key, GVariant **data,
 
        devc = sdi->priv;
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_SAMPLERATE:
                *data = g_variant_new_uint64(devc->cur_samplerate);
@@ -348,13 +346,12 @@ static int config_get(uint32_t key, GVariant **data,
                return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_set(uint32_t key, GVariant *data,
        const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
-       int ret;
        struct dev_context *devc;
        uint64_t value;
 
@@ -362,13 +359,11 @@ static int config_set(uint32_t key, GVariant *data,
 
        devc = sdi->priv;
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_LIMIT_MSEC:
                value = g_variant_get_uint64(data);
                /* TODO: Implement. */
-               ret = SR_ERR_NA;
-               break;
+               return SR_ERR_NA;
        case SR_CONF_LIMIT_SAMPLES:
                if (g_variant_get_uint64(data) == 0)
                        return SR_ERR_ARG;
@@ -381,23 +376,21 @@ static int config_set(uint32_t key, GVariant *data,
                devc->cur_samplerate = value;
                return ftdi_la_set_samplerate(devc);
        default:
-               ret = SR_ERR_NA;
+               return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_list(uint32_t key, GVariant **data,
        const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
-       int ret;
        GVariant *gvar;
        GVariantBuilder gvb;
 
        (void)sdi;
        (void)cg;
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_SCAN_OPTIONS:
                *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
@@ -418,7 +411,7 @@ static int config_list(uint32_t key, GVariant **data,
                return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int dev_acquisition_start(const struct sr_dev_inst *sdi)
index f94fc851c7dea68273dd2e212e3b0d47d30bed12..bc3ac2f94fe5aa105e091594bbd1aba289a53be7 100644 (file)
@@ -338,7 +338,6 @@ static int dev_close(struct sr_dev_inst *sdi)
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
-       int ret;
        struct dev_context *devc;
 
        (void)cg;
@@ -348,7 +347,6 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
 
        devc = sdi->priv;
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_LIMIT_SAMPLES:
        case SR_CONF_LIMIT_MSEC:
@@ -360,7 +358,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
                return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 /** Implementation of config_list, auxiliary function for common parts. */
index 6bdcdb1f9dc7b24485e648e63001c69163c60538..dd995952d30062806daa86f739fcd193303bd872 100644 (file)
@@ -393,11 +393,10 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
 {
        struct dev_context *devc;
        uint64_t p, q;
-       int tmp_int, ch_idx, ret;
+       int tmp_int, ch_idx;
        unsigned int i;
        const char *tmp_str;
 
-       ret = SR_OK;
        devc = sdi->priv;
        if (!cg) {
                switch (key) {
@@ -412,8 +411,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                        devc->limit_samples = g_variant_get_uint64(data);
                        break;
                default:
-                       ret = SR_ERR_NA;
-                       break;
+                       return SR_ERR_NA;
                }
        } else {
                if (sdi->channel_groups->data == cg)
@@ -436,7 +434,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                                devc->voltage[ch_idx] = tmp_int;
                                hantek_6xxx_update_vdiv(sdi);
                        } else
-                               ret = SR_ERR_ARG;
+                               return SR_ERR_ARG;
                        break;
                case SR_CONF_COUPLING:
                        tmp_str = g_variant_get_string(data, NULL);
@@ -447,15 +445,14 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                                }
                        }
                        if (i == devc->coupling_tab_size)
-                               ret = SR_ERR_ARG;
+                               return SR_ERR_ARG;
                        break;
                default:
-                       ret = SR_ERR_NA;
-                       break;
+                       return SR_ERR_NA;
                }
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
index 4b911c28db41ffaf5cc6e0d13585bc6e69753b91..dc94f033c806c527e8277964dd3b83a983f15597 100644 (file)
@@ -483,11 +483,10 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
        struct dev_context *devc;
        double tmp_double;
        uint64_t tmp_u64, p, q;
-       int tmp_int, ch_idx, ret;
+       int tmp_int, ch_idx;
        unsigned int i;
        const char *tmp_str;
 
-       ret = SR_OK;
        devc = sdi->priv;
        if (!cg) {
                switch (key) {
@@ -505,7 +504,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                        tmp_double = g_variant_get_double(data);
                        if (tmp_double < 0.0 || tmp_double > 1.0) {
                                sr_err("Trigger position should be between 0.0 and 1.0.");
-                               ret = SR_ERR_ARG;
+                               return SR_ERR_ARG;
                        } else
                                devc->triggerposition = tmp_double;
                        break;
@@ -518,7 +517,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                                }
                        }
                        if (i == NUM_BUFFER_SIZES)
-                               ret = SR_ERR_ARG;
+                               return SR_ERR_ARG;
                        break;
                case SR_CONF_TIMEBASE:
                        g_variant_get(data, "(tt)", &p, &q);
@@ -532,7 +531,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                        if (tmp_int >= 0)
                                devc->timebase = tmp_int;
                        else
-                               ret = SR_ERR_ARG;
+                               return SR_ERR_ARG;
                        break;
                case SR_CONF_TRIGGER_SOURCE:
                        tmp_str = g_variant_get_string(data, NULL);
@@ -543,11 +542,10 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                                }
                        }
                        if (trigger_sources[i] == 0)
-                               ret = SR_ERR_ARG;
+                               return SR_ERR_ARG;
                        break;
                default:
-                       ret = SR_ERR_NA;
-                       break;
+                       return SR_ERR_NA;
                }
        } else {
                if (sdi->channel_groups->data == cg)
@@ -572,7 +570,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                        if (tmp_int >= 0) {
                                devc->voltage[ch_idx] = tmp_int;
                        } else
-                               ret = SR_ERR_ARG;
+                               return SR_ERR_ARG;
                        break;
                case SR_CONF_COUPLING:
                        tmp_str = g_variant_get_string(data, NULL);
@@ -583,15 +581,14 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                                }
                        }
                        if (coupling[i] == 0)
-                               ret = SR_ERR_ARG;
+                               return SR_ERR_ARG;
                        break;
                default:
-                       ret = SR_ERR_NA;
-                       break;
+                       return SR_ERR_NA;
                }
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
index 873fbc07e8a40219aaccc6cc360b1153f71feaeb..5c6ea7121e18ae4ba719e156998536e0bfdacb78 100644 (file)
@@ -225,14 +225,12 @@ static int dev_close(struct sr_dev_inst *sdi)
 static int config_get(uint32_t key, GVariant **data,
        const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
-       int ret;
        struct dev_context *devc;
 
        (void)cg;
 
        devc = sdi->priv;
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_ADC_POWERLINE_CYCLES:
                *data = g_variant_new_double(devc->nplc);
@@ -241,7 +239,7 @@ static int config_get(uint32_t key, GVariant **data,
                return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_set(uint32_t key, GVariant *data,
@@ -284,8 +282,6 @@ static int config_set(uint32_t key, GVariant *data,
 static int config_list(uint32_t key, GVariant **data,
        const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
-       int ret;
-
        if (key == SR_CONF_SCAN_OPTIONS) {
                *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
                        scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t));
@@ -309,13 +305,12 @@ static int config_list(uint32_t key, GVariant **data,
         * plug-in cards.
         */
 
-       ret = SR_OK;
        switch (key) {
        default:
-               ret = SR_ERR_NA;
+               return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static void create_channel_index_list(GSList *channels, GArray **arr)
index 484f8768f18dbb3a8d0383c7666f61966c9e7373..a3aee05f18458eb401f8983b3d5699a233d487e4 100644 (file)
@@ -341,12 +341,11 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
 {
        struct dev_context *devc = sdi->priv;
        struct parport *port;
-       int ret, i, ch = -1;
+       int i, ch = -1;
 
        if (cg) /* sr_config_get will validate cg using config_list */
                ch = ((struct sr_channel *)cg->channels->data)->index;
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_CONN:
                port = sdi->conn;
@@ -362,13 +361,13 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
                i = reverse_map(devc->cctl[0] & 0xC0, trigger_sources_map,
                                ARRAY_SIZE(trigger_sources_map));
                if (i == -1)
-                       ret = SR_ERR;
+                       return SR_ERR;
                else
                        *data = g_variant_new_string(trigger_sources[i]);
                break;
        case SR_CONF_TRIGGER_SLOPE:
                if (devc->edge >= ARRAY_SIZE(trigger_slopes))
-                       ret = SR_ERR;
+                       return SR_ERR;
                else
                        *data = g_variant_new_string(trigger_slopes[devc->edge]);
                break;
@@ -377,12 +376,12 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
                break;
        case SR_CONF_VDIV:
                if (ch == -1) {
-                       ret = SR_ERR_CHANNEL_GROUP;
+                       return SR_ERR_CHANNEL_GROUP;
                } else {
                        i = reverse_map(devc->cctl[ch] & 0x33, vdivs_map,
                                        ARRAY_SIZE(vdivs_map));
                        if (i == -1)
-                               ret = SR_ERR;
+                               return SR_ERR;
                        else
                                *data = g_variant_new("(tt)", vdivs[i][0],
                                                      vdivs[i][1]);
@@ -390,40 +389,39 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
                break;
        case SR_CONF_COUPLING:
                if (ch == -1) {
-                       ret = SR_ERR_CHANNEL_GROUP;
+                       return SR_ERR_CHANNEL_GROUP;
                } else {
                        i = reverse_map(devc->cctl[ch] & 0x0C, coupling_map,
                                        ARRAY_SIZE(coupling_map));
                        if (i == -1)
-                               ret = SR_ERR;
+                               return SR_ERR;
                        else
                                *data = g_variant_new_string(coupling[i]);
                }
                break;
        case SR_CONF_PROBE_FACTOR:
                if (ch == -1)
-                       ret = SR_ERR_CHANNEL_GROUP;
+                       return SR_ERR_CHANNEL_GROUP;
                else
                        *data = g_variant_new_uint64(devc->probe[ch]);
                break;
        default:
-               ret = SR_ERR_NA;
+               return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 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 = sdi->priv;
-       int ret, i, ch = -1;
+       int i, ch = -1;
        uint64_t u, v;
 
        if (cg) /* sr_config_set will validate cg using config_list */
                ch = ((struct sr_channel *)cg->channels->data)->index;
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_LIMIT_FRAMES:
                devc->frame_limit = g_variant_get_uint64(data);
@@ -432,7 +430,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                i = find_in_array(data, G_VARIANT_TYPE_UINT64,
                                  samplerates, ARRAY_SIZE(samplerates));
                if (i == -1)
-                       ret = SR_ERR_ARG;
+                       return SR_ERR_ARG;
                else
                        devc->rate = i;
                break;
@@ -440,7 +438,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                i = find_in_array(data, G_VARIANT_TYPE_STRING,
                                  trigger_sources, ARRAY_SIZE(trigger_sources));
                if (i == -1)
-                       ret = SR_ERR_ARG;
+                       return SR_ERR_ARG;
                else
                        devc->cctl[0] = (devc->cctl[0] & 0x3F)
                                      | trigger_sources_map[i];
@@ -449,7 +447,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                i = find_in_array(data, G_VARIANT_TYPE_STRING,
                                  trigger_slopes, ARRAY_SIZE(trigger_slopes));
                if (i == -1)
-                       ret = SR_ERR_ARG;
+                       return SR_ERR_ARG;
                else
                        devc->edge = i;
                break;
@@ -457,22 +455,22 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                i = find_in_array(data, G_VARIANT_TYPE_UINT64,
                                  buffersizes, ARRAY_SIZE(buffersizes));
                if (i == -1)
-                       ret = SR_ERR_ARG;
+                       return SR_ERR_ARG;
                else
                        devc->last_step = i;
                break;
        case SR_CONF_VDIV:
                if (ch == -1) {
-                       ret = SR_ERR_CHANNEL_GROUP;
+                       return SR_ERR_CHANNEL_GROUP;
                } else if (!g_variant_is_of_type(data, G_VARIANT_TYPE("(tt)"))) {
-                       ret = SR_ERR_ARG;
+                       return SR_ERR_ARG;
                } else {
                        g_variant_get(data, "(tt)", &u, &v);
                        for (i = 0; i < (int)ARRAY_SIZE(vdivs); i++)
                                if (vdivs[i][0] == u && vdivs[i][1] == v)
                                        break;
                        if (i == ARRAY_SIZE(vdivs))
-                               ret = SR_ERR_ARG;
+                               return SR_ERR_ARG;
                        else
                                devc->cctl[ch] = (devc->cctl[ch] & 0xCC)
                                               | vdivs_map[i];
@@ -480,12 +478,12 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                break;
        case SR_CONF_COUPLING:
                if (ch == -1) {
-                       ret = SR_ERR_CHANNEL_GROUP;
+                       return SR_ERR_CHANNEL_GROUP;
                } else {
                        i = find_in_array(data, G_VARIANT_TYPE_STRING,
                                          coupling, ARRAY_SIZE(coupling));
                        if (i == -1)
-                               ret = SR_ERR_ARG;
+                               return SR_ERR_ARG;
                        else
                                devc->cctl[ch] = (devc->cctl[ch] & 0xF3)
                                               | coupling_map[i];
@@ -493,20 +491,20 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                break;
        case SR_CONF_PROBE_FACTOR:
                if (ch == -1) {
-                       ret = SR_ERR_CHANNEL_GROUP;
+                       return SR_ERR_CHANNEL_GROUP;
                } else {
                        u = g_variant_get_uint64(data);
                        if (!u)
-                               ret = SR_ERR_ARG;
+                               return SR_ERR_ARG;
                        else
                                devc->probe[ch] = u;
                }
                break;
        default:
-               ret = SR_ERR_NA;
+               return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_channel_set(const struct sr_dev_inst *sdi,
index 6c336cb107aff8c0d330da53823e415e669e840d..4afaf30a9f5b42495c7eb66df7b6f07b9721cf8a 100644 (file)
@@ -303,12 +303,10 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
 {
        GVariant *gvar, *grange[2];
        GVariantBuilder gvb;
-       int ret;
 
        (void)sdi;
        (void)cg;
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_DEVICE_OPTIONS:
                *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
@@ -336,7 +334,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int dev_acquisition_start(const struct sr_dev_inst *sdi)
index 15dda4e09d72a96b91510881a10ebb978c1255c6..b294b8073bce09e63dc724bca7386f96e2c5cf9f 100644 (file)
@@ -253,13 +253,12 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
        struct dev_context *devc;
        uint64_t p, q;
        unsigned int i;
-       int tmp, ret;
+       int tmp;
        const char *tmp_str;
 
        (void)cg;
 
        devc = sdi->priv;
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_LIMIT_SAMPLES:
                devc->limit_samples = g_variant_get_uint64(data);
@@ -276,7 +275,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                        break;
                }
                if (i == ARRAY_SIZE(kecheng_kc_330b_sample_intervals))
-                       ret = SR_ERR_ARG;
+                       return SR_ERR_ARG;
                break;
        case SR_CONF_SPL_WEIGHT_FREQ:
                tmp_str = g_variant_get_string(data, NULL);
@@ -313,10 +312,10 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                devc->config_dirty = TRUE;
                break;
        default:
-               ret = SR_ERR_NA;
+               return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
index 34b50b7ae33d91e6c325d05c79f81608b1befb9d..1f150faeb6281c9e0850ce094fe1147ca27d0f0e 100644 (file)
@@ -145,7 +145,6 @@ static int dev_close(struct sr_dev_inst *sdi)
 static int config_get(uint32_t key, GVariant **data,
        const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
-       int ret;
        unsigned int i;
        struct dev_context *devc;
        const struct scope_config *model;
@@ -156,7 +155,6 @@ static int config_get(uint32_t key, GVariant **data,
 
        devc = sdi->priv;
 
-       ret = SR_ERR_NA;
        model = devc->model_config;
        state = devc->model_state;
        *data = NULL;
@@ -164,20 +162,17 @@ static int config_get(uint32_t key, GVariant **data,
        switch (key) {
        case SR_CONF_NUM_HDIV:
                *data = g_variant_new_int32(model->num_xdivs);
-               ret = SR_OK;
                break;
        case SR_CONF_TIMEBASE:
                *data = g_variant_new("(tt)",
                                model->timebases[state->timebase].p,
                                model->timebases[state->timebase].q);
-               ret = SR_OK;
                break;
        case SR_CONF_NUM_VDIV:
                for (i = 0; i < model->analog_channels; i++) {
                        if (cg != devc->analog_groups[i])
                                continue;
                        *data = g_variant_new_int32(model->num_ydivs);
-                       ret = SR_OK;
                }
                break;
        case SR_CONF_VDIV:
@@ -187,42 +182,35 @@ static int config_get(uint32_t key, GVariant **data,
                        *data = g_variant_new("(tt)",
                                model->vdivs[state->analog_channels[i].vdiv].p,
                                model->vdivs[state->analog_channels[i].vdiv].q);
-                       ret = SR_OK;
                }
                break;
        case SR_CONF_TRIGGER_SOURCE:
                *data = g_variant_new_string((*model->trigger_sources)[state->trigger_source]);
-               ret = SR_OK;
                break;
        case SR_CONF_TRIGGER_SLOPE:
                *data = g_variant_new_string((*model->trigger_slopes)[state->trigger_slope]);
-               ret = SR_OK;
                break;
        case SR_CONF_HORIZ_TRIGGERPOS:
                *data = g_variant_new_double(state->horiz_triggerpos);
-               ret = SR_OK;
                break;
        case SR_CONF_COUPLING:
                for (i = 0; i < model->analog_channels; i++) {
                        if (cg != devc->analog_groups[i])
                                continue;
                        *data = g_variant_new_string((*model->coupling_options)[state->analog_channels[i].coupling]);
-                       ret = SR_OK;
                }
                break;
        case SR_CONF_SAMPLERATE:
                *data = g_variant_new_uint64(state->sample_rate);
-               ret = SR_OK;
                break;
        case SR_CONF_ENABLED:
                *data = g_variant_new_boolean(FALSE);
-               ret = SR_OK;
                break;
        default:
-               ret = SR_ERR_NA;
+               return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static GVariant *build_tuples(const struct sr_rational *array, unsigned int n)
index 00be6ac416b205d6639811628af0bd4d36e03e5c..bd33d9f2c2ad451fad18236b444f82f8a866670d 100644 (file)
@@ -236,24 +236,21 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi,
 
        devc = sdi->priv;
 
+       ret = SR_OK;
        switch (key) {
        case SR_CONF_SAMPLERATE:
                // FIXME
                return mso_configure_rate(sdi, g_variant_get_uint64(data));
-               ret = SR_OK;
-               break;
        case SR_CONF_LIMIT_SAMPLES:
                num_samples = g_variant_get_uint64(data);
                if (num_samples != 1024) {
                        sr_err("Only 1024 samples are supported.");
                        ret = SR_ERR_ARG;
-               } else {
-                       devc->limit_samples = num_samples;
-                       ret = SR_OK;
-               }
+                       break;
+               };
+               devc->limit_samples = num_samples;
                break;
        case SR_CONF_CAPTURE_RATIO:
-               ret = SR_OK;
                break;
        case SR_CONF_TRIGGER_SLOPE:
                slope = g_variant_get_string(data, NULL);
@@ -261,29 +258,25 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi,
                if (!slope || !(slope[0] == 'f' || slope[0] == 'r'))
                        sr_err("Invalid trigger slope");
                        ret = SR_ERR_ARG;
-               } else {
-                       devc->trigger_slope = (slope[0] == 'r')
-                               ? SLOPE_POSITIVE : SLOPE_NEGATIVE;
-                       ret = SR_OK;
+                       break;
                }
+               devc->trigger_slope = (slope[0] == 'r')
+                       ? SLOPE_POSITIVE : SLOPE_NEGATIVE;
                break;
        case SR_CONF_HORIZ_TRIGGERPOS:
                pos = g_variant_get_double(data);
                if (pos < 0 || pos > 255) {
                        sr_err("Trigger position (%f) should be between 0 and 255.", pos);
                        ret = SR_ERR_ARG;
-               } else {
-                       trigger_pos = (int)pos;
-                       devc->trigger_holdoff[0] = trigger_pos & 0xff;
-                       ret = SR_OK;
+                       break;
                }
+               trigger_pos = (int)pos;
+               devc->trigger_holdoff[0] = trigger_pos & 0xff;
                break;
        case SR_CONF_RLE:
-               ret = SR_OK;
                break;
        default:
                ret = SR_ERR_NA;
-               break;
        }
 
        return ret;
index 876150a28609ea78ced4be63fc7066fcc5d9ffba..45bcf9700167e3ba5702c17267ab56fa7d57ee58 100644 (file)
@@ -361,7 +361,6 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
 {
        struct dev_context *devc;
        GVariantBuilder gvb;
-       int ret;
 
        /* Always available, even without sdi. */
        if (key == SR_CONF_SCAN_OPTIONS) {
@@ -378,7 +377,6 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                return SR_ERR_ARG;
        devc = sdi->priv;
 
-       ret = SR_OK;
        if (!cg) {
                /* No channel group: global options. */
                switch (key) {
@@ -416,7 +414,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                }
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int dev_acquisition_start(const struct sr_dev_inst *sdi)
index ef4f49500fa8cb9738ac5d540bc7311ebc026f56..8191e8da7cc1529d8203a9ed0dd210650c99d2a2 100644 (file)
@@ -215,11 +215,9 @@ static int config_get(uint32_t key, GVariant **data,
 {
        struct sr_usb_dev_inst *usb;
        struct dev_context *devc;
-       int ret;
 
        (void)cg;
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_CONN:
                if (!sdi || !sdi->conn)
@@ -237,29 +235,27 @@ static int config_get(uint32_t key, GVariant **data,
                return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 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;
-       int ret;
 
        (void)cg;
 
        devc = sdi->priv;
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_SAMPLERATE:
                devc->dig_samplerate = g_variant_get_uint64(data);
                break;
        default:
-               ret = SR_ERR_NA;
+               return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_list(uint32_t key, GVariant **data,
@@ -267,12 +263,10 @@ static int config_list(uint32_t key, GVariant **data,
 {
        GVariant *gvar;
        GVariantBuilder gvb;
-       int ret;
 
        (void)sdi;
        (void)cg;
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_SCAN_OPTIONS:
                *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
@@ -298,7 +292,7 @@ static int config_list(uint32_t key, GVariant **data,
                return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static void dev_acquisition_abort(const struct sr_dev_inst *sdi)
index 0400ce8375a6c2ce72a0fe3cce8e88f506280a34..721f15a540628f629aad397f5f428e26aff431d0 100644 (file)
@@ -501,13 +501,11 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
 {
        GVariant *gvar, *range[2];
        GVariantBuilder gvb;
-       int ret;
        unsigned int i;
 
        (void)sdi;
        (void)cg;
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_SCAN_OPTIONS:
                *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
@@ -543,7 +541,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static void abort_acquisition(struct dev_context *devc)
index 6b73f121d235344473e394d160e68131f063ffe7..5d2488252aa0a5e154ea9a096f7cc1cdce5fd075 100644 (file)
@@ -517,7 +517,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
        const struct channel_spec *ch_spec;
        GVariant *gvar;
        GVariantBuilder gvb;
-       int ret, i;
+       int i;
        const char *s[16];
 
        /* Always available, even without sdi. */
@@ -535,7 +535,6 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                return SR_ERR_ARG;
        devc = sdi->priv;
 
-       ret = SR_OK;
        if (!cg) {
                /* No channel group: global options. */
                switch (key) {
@@ -616,7 +615,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                }
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int dev_acquisition_start(const struct sr_dev_inst *sdi)