]> sigrok.org Git - libsigrok.git/commitdiff
drivers: Remove some unneeded 'ret' variables.
authorUwe Hermann <redacted>
Fri, 28 Jul 2017 20:56:09 +0000 (22:56 +0200)
committerUwe Hermann <redacted>
Mon, 31 Jul 2017 14:23:31 +0000 (16:23 +0200)
24 files changed:
src/hardware/agilent-dmm/api.c
src/hardware/arachnid-labs-re-load-pro/api.c
src/hardware/asix-sigma/api.c
src/hardware/atten-pps3xxx/api.c
src/hardware/baylibre-acme/api.c
src/hardware/cem-dt-885x/api.c
src/hardware/conrad-digi-35-cpu/api.c
src/hardware/dreamsourcelab-dslogic/api.c
src/hardware/fx2lafw/api.c
src/hardware/hameg-hmo/api.c
src/hardware/hp-3457a/api.c
src/hardware/ikalogic-scanalogic2/api.c
src/hardware/kecheng-kc-330b/api.c
src/hardware/lascar-el-usb/api.c
src/hardware/lecroy-xstream/api.c
src/hardware/link-mso19/api.c
src/hardware/maynuo-m97/api.c
src/hardware/motech-lps-30x/api.c
src/hardware/openbench-logic-sniffer/api.c
src/hardware/pce-322a/api.c
src/hardware/pipistrello-ols/api.c
src/hardware/rigol-ds/api.c
src/hardware/saleae-logic16/api.c
src/hardware/scpi-pps/api.c

index 293b5f84c4336919916a113bdc08f05b737dfa42..c410b37c02a02276810f9f40e9e2c1655057f007 100644 (file)
@@ -187,21 +187,18 @@ 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;
 
        (void)cg;
 
        devc = sdi->priv;
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_SAMPLERATE:
                *data = g_variant_new_uint64(devc->cur_samplerate);
                break;
        case SR_CONF_LIMIT_SAMPLES:
        case SR_CONF_LIMIT_MSEC:
-               ret = sr_sw_limits_config_get(&devc->limits, key, data);
-               break;
+               return sr_sw_limits_config_get(&devc->limits, key, data);
        case SR_CONF_DATA_SOURCE:
                *data = g_variant_new_string(data_sources[devc->data_source]);
                break;
@@ -209,7 +206,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,
@@ -217,35 +214,32 @@ static int config_set(uint32_t key, GVariant *data,
 {
        struct dev_context *devc;
        uint64_t samplerate;
-       int ret, idx;
+       int idx;
 
        (void)cg;
 
        devc = sdi->priv;
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_SAMPLERATE:
                samplerate = g_variant_get_uint64(data);
                if (samplerate < samplerates[0] || samplerate > samplerates[1])
-                       ret = SR_ERR_ARG;
-               else
-                       devc->cur_samplerate = g_variant_get_uint64(data);
+                       return SR_ERR_ARG;
+               devc->cur_samplerate = g_variant_get_uint64(data);
                break;
        case SR_CONF_LIMIT_SAMPLES:
        case SR_CONF_LIMIT_MSEC:
-               ret = sr_sw_limits_config_set(&devc->limits, key, data);
-               break;
+               return sr_sw_limits_config_set(&devc->limits, key, data);
        case SR_CONF_DATA_SOURCE:
                if ((idx = std_str_idx(data, ARRAY_AND_SIZE(data_sources))) < 0)
                        return SR_ERR_ARG;
                devc->data_source = idx;
                break;
        default:
-               ret = SR_ERR_NA;
+               return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_list(uint32_t key, GVariant **data,
index 0aa2b7bff9794c535da67279fd62f45634b40a2c..77b7dd7f80541f431216b3d179ce12e146dd7fc3 100644 (file)
@@ -237,29 +237,24 @@ 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_LIMIT_SAMPLES:
        case SR_CONF_LIMIT_MSEC:
                return sr_sw_limits_config_set(&devc->limits, key, data);
        case SR_CONF_ENABLED:
-               ret = reloadpro_set_on_off(sdi, g_variant_get_boolean(data));
-               break;
+               return reloadpro_set_on_off(sdi, g_variant_get_boolean(data));
        case SR_CONF_CURRENT_LIMIT:
-               ret = reloadpro_set_current_limit(sdi,
-                       g_variant_get_double(data));
-               break;
+               return reloadpro_set_current_limit(sdi, g_variant_get_double(data));
        default:
-               ret = SR_ERR_NA;
+               return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int dev_acquisition_start(const struct sr_dev_inst *sdi)
index d2667f09fd5168c1431f7744b738d48e58779cdb..96cdb2a787ad4653cbc7f7394684f4c5aa4da797 100644 (file)
@@ -194,17 +194,14 @@ static int config_set(uint32_t key, GVariant *data,
 {
        struct dev_context *devc;
        uint64_t tmp;
-       int ret;
 
        (void)cg;
 
        devc = sdi->priv;
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_SAMPLERATE:
-               ret = sigma_set_samplerate(sdi, g_variant_get_uint64(data));
-               break;
+               return sigma_set_samplerate(sdi, g_variant_get_uint64(data));
        case SR_CONF_LIMIT_MSEC:
                devc->limit_msec = g_variant_get_uint64(data);
                break;
@@ -222,10 +219,10 @@ static int config_set(uint32_t key, GVariant *data,
                break;
 #endif
        default:
-               ret = SR_ERR_NA;
+               return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_list(uint32_t key, GVariant **data,
index b87d230df0684cf690e6467aa0e0d026b090e50e..f08671fb1081b28083601d0113c7afad8b4a0ccd 100644 (file)
@@ -240,31 +240,27 @@ static int config_set(uint32_t key, GVariant *data,
        struct dev_context *devc;
        struct sr_channel *ch;
        gdouble dval;
-       int channel, ret, ival;
+       int channel, ival;
        gboolean bval;
 
-       ret = SR_OK;
        devc = sdi->priv;
+
        if (!cg) {
                switch (key) {
                case SR_CONF_CHANNEL_CONFIG:
                        if ((ival = std_str_idx(data, ARRAY_AND_SIZE(channel_modes))) < 0)
                                return SR_ERR_ARG;
-                       if (devc->model->channel_modes && (1 << ival) == 0) {
-                               /* Not supported on this model. */
-                               ret = SR_ERR_ARG;
-                       }
+                       if (devc->model->channel_modes && (1 << ival) == 0)
+                               return SR_ERR_ARG; /* Not supported on this model. */
                        if (ival == devc->channel_mode_set)
-                               /* Nothing to do. */
-                               break;
+                               break; /* Nothing to do. */
                        devc->channel_mode_set = ival;
                        devc->config_dirty = TRUE;
                        break;
                case SR_CONF_OVER_CURRENT_PROTECTION_ENABLED:
                        bval = g_variant_get_boolean(data);
                        if (bval == devc->over_current_protection_set)
-                               /* Nothing to do. */
-                               break;
+                               break; /* Nothing to do. */
                        devc->over_current_protection_set = bval;
                        devc->config_dirty = TRUE;
                        break;
@@ -280,31 +276,30 @@ static int config_set(uint32_t key, GVariant *data,
                case SR_CONF_VOLTAGE_TARGET:
                        dval = g_variant_get_double(data);
                        if (dval < 0 || dval > devc->model->channels[channel].voltage[1])
-                               ret = SR_ERR_ARG;
+                               return SR_ERR_ARG;
                        devc->config[channel].output_voltage_max = dval;
                        devc->config_dirty = TRUE;
                        break;
                case SR_CONF_CURRENT_LIMIT:
                        dval = g_variant_get_double(data);
                        if (dval < 0 || dval > devc->model->channels[channel].current[1])
-                               ret = SR_ERR_ARG;
+                               return SR_ERR_ARG;
                        devc->config[channel].output_current_max = dval;
                        devc->config_dirty = TRUE;
                        break;
                case SR_CONF_ENABLED:
                        bval = g_variant_get_boolean(data);
                        if (bval == devc->config[channel].output_enabled_set)
-                               /* Nothing to do. */
-                               break;
+                               break; /* Nothing to do. */
                        devc->config[channel].output_enabled_set = bval;
                        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,
index b824720ded820a5e3fd354c13ce3be833a29e934..5dd05c579417ff0db39aa8f4825e7c9d16ce36c8 100644 (file)
@@ -142,11 +142,11 @@ static int config_get(uint32_t key, GVariant **data,
        devc = sdi->priv;
 
        ret = SR_OK;
+
        switch (key) {
        case SR_CONF_LIMIT_SAMPLES:
        case SR_CONF_LIMIT_MSEC:
-               ret = sr_sw_limits_config_get(&devc->limits, key, data);
-               break;
+               return sr_sw_limits_config_get(&devc->limits, key, data);
        case SR_CONF_SAMPLERATE:
                *data = g_variant_new_uint64(devc->samplerate);
                break;
@@ -176,22 +176,18 @@ static int config_set(uint32_t key, GVariant *data,
 {
        struct dev_context *devc;
        uint64_t samplerate;
-       int ret;
 
        devc = sdi->priv;
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_LIMIT_SAMPLES:
        case SR_CONF_LIMIT_MSEC:
-               ret = sr_sw_limits_config_set(&devc->limits, key, data);
-               break;
+               return sr_sw_limits_config_set(&devc->limits, key, data);
        case SR_CONF_SAMPLERATE:
                samplerate = g_variant_get_uint64(data);
                if (samplerate > MAX_SAMPLE_RATE) {
                        sr_err("Maximum sample rate is %d", MAX_SAMPLE_RATE);
-                       ret = SR_ERR_SAMPLERATE;
-                       break;
+                       return SR_ERR_SAMPLERATE;
                }
                devc->samplerate = samplerate;
                bl_acme_maybe_set_update_interval(sdi, samplerate);
@@ -199,18 +195,16 @@ static int config_set(uint32_t key, GVariant *data,
        case SR_CONF_PROBE_FACTOR:
                if (!cg)
                        return SR_ERR_CHANNEL_GROUP;
-               ret = bl_acme_set_shunt(cg, g_variant_get_uint64(data));
-               break;
+               return bl_acme_set_shunt(cg, g_variant_get_uint64(data));
        case SR_CONF_POWER_OFF:
                if (!cg)
                        return SR_ERR_CHANNEL_GROUP;
-               ret = bl_acme_set_power_off(cg, g_variant_get_boolean(data));
-               break;
+               return bl_acme_set_power_off(cg, g_variant_get_boolean(data));
        default:
-               ret = SR_ERR_NA;
+               return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_list(uint32_t key, GVariant **data,
index c2177b30ed0752738a9959ef861dc932af28b6c1..6db50a90d1b9cf38b9d879f03c03213ba9dca929 100644 (file)
@@ -138,7 +138,9 @@ static int config_get(uint32_t key, GVariant **data,
                return SR_ERR_ARG;
 
        devc = sdi->priv;
+
        ret = SR_OK;
+
        switch (key) {
        case SR_CONF_LIMIT_SAMPLES:
                *data = g_variant_new_uint64(devc->limit_samples);
@@ -197,20 +199,18 @@ 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 tmp, ret, idx;
+       int tmp, idx;
 
        (void)cg;
 
        devc = sdi->priv;
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_LIMIT_SAMPLES:
                devc->limit_samples = g_variant_get_uint64(data);
                break;
        case SR_CONF_DATALOG:
-               ret = cem_dt_885x_recording_set(sdi, g_variant_get_boolean(data));
-               break;
+               return cem_dt_885x_recording_set(sdi, g_variant_get_boolean(data));
        case SR_CONF_SPL_WEIGHT_FREQ:
                if ((idx = std_str_idx(data, ARRAY_AND_SIZE(weight_freq))) < 0)
                        return SR_ERR_ARG;
@@ -223,19 +223,17 @@ static int config_set(uint32_t key, GVariant *data,
                        SR_MQFLAG_SPL_TIME_WEIGHT_F : SR_MQFLAG_SPL_TIME_WEIGHT_S);
        case SR_CONF_HOLD_MAX:
                tmp = g_variant_get_boolean(data) ? SR_MQFLAG_MAX : 0;
-               ret = cem_dt_885x_holdmode_set(sdi, tmp);
-               break;
+               return cem_dt_885x_holdmode_set(sdi, tmp);
        case SR_CONF_HOLD_MIN:
                tmp = g_variant_get_boolean(data) ? SR_MQFLAG_MIN : 0;
-               ret = cem_dt_885x_holdmode_set(sdi, tmp);
-               break;
+               return cem_dt_885x_holdmode_set(sdi, tmp);
        case SR_CONF_SPL_MEASUREMENT_RANGE:
                if ((idx = std_u64_tuple_idx(data, ARRAY_AND_SIZE(meas_ranges))) < 0)
                        return SR_ERR_ARG;
                return cem_dt_885x_meas_range_set(sdi, meas_ranges[idx][0], meas_ranges[idx][1]);
        case SR_CONF_POWER_OFF:
                if (g_variant_get_boolean(data))
-                       ret = cem_dt_885x_power_off(sdi);
+                       return cem_dt_885x_power_off(sdi);
                break;
        case SR_CONF_DATA_SOURCE:
                if ((idx = std_str_idx(data, ARRAY_AND_SIZE(data_sources))) < 0)
@@ -244,10 +242,10 @@ static int config_set(uint32_t key, GVariant *data,
                devc->enable_data_source_memory = (idx == DATA_SOURCE_MEMORY);
                break;
        default:
-               ret = SR_ERR_NA;
+               return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_list(uint32_t key, GVariant **data,
index 7991b815c6ab9e68b06eb327d714ad042502cbf6..1f0d220a058bfab5768a48a0885fcb8ed614750a 100644 (file)
@@ -93,7 +93,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
 static int config_set(uint32_t key, GVariant *data,
        const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
-       int ret;
        double dblval;
 
        (void)cg;
@@ -105,27 +104,24 @@ static int config_set(uint32_t key, GVariant *data,
                        sr_err("Voltage out of range (0 - 35.0)!");
                        return SR_ERR_ARG;
                }
-               ret = send_msg1(sdi, 'V', (int) (dblval * 10 + 0.5));
-               break;
+               return send_msg1(sdi, 'V', (int) (dblval * 10 + 0.5));
        case SR_CONF_CURRENT:
                dblval = g_variant_get_double(data);
                if ((dblval < 0.01) || (dblval > 2.55)) {
                        sr_err("Current out of range (0 - 2.55)!");
                        return SR_ERR_ARG;
                }
-               ret = send_msg1(sdi, 'C', (int) (dblval * 100 + 0.5));
-               break;
+               return send_msg1(sdi, 'C', (int) (dblval * 100 + 0.5));
        case SR_CONF_OVER_CURRENT_PROTECTION_ENABLED:
                if (g_variant_get_boolean(data))
-                       ret = send_msg1(sdi, 'V', 900);
+                       return send_msg1(sdi, 'V', 900);
                else /* Constant current mode */
-                       ret = send_msg1(sdi, 'V', 901);
-               break;
+                       return send_msg1(sdi, 'V', 901);
        default:
-               ret = SR_ERR_NA;
+               return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_list(uint32_t key, GVariant **data,
index 83090f2d147a0823ac4520ad5d016a00a2fa66ca..4e0a1d10016eddff95be28ad75e3f12817dbe5cd 100644 (file)
@@ -443,7 +443,7 @@ 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 idx, ret;
+       int idx;
        gdouble low, high;
 
        (void)cg;
@@ -453,8 +453,6 @@ static int config_set(uint32_t key, GVariant *data,
 
        devc = sdi->priv;
 
-       ret = SR_OK;
-
        switch (key) {
        case SR_CONF_SAMPLERATE:
                if ((idx = std_u64_idx(data, devc->samplerates, devc->num_samplerates)) < 0)
@@ -466,17 +464,16 @@ static int config_set(uint32_t key, GVariant *data,
                break;
        case SR_CONF_CAPTURE_RATIO:
                devc->capture_ratio = g_variant_get_uint64(data);
-               ret = (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
-               break;
+               return (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
        case SR_CONF_VOLTAGE_THRESHOLD:
                if (!strcmp(devc->profile->model, "DSLogic")) {
                        if ((idx = std_double_tuple_idx(data, ARRAY_AND_SIZE(voltage_thresholds))) < 0)
                                return SR_ERR_ARG;
                        devc->cur_threshold = voltage_thresholds[idx][0];
-                       ret = dslogic_fpga_firmware_upload(sdi);
+                       return dslogic_fpga_firmware_upload(sdi);
                } else {
                        g_variant_get(data, "(dd)", &low, &high);
-                       ret = dslogic_set_voltage_threshold(sdi, (low + high) / 2.0);
+                       return dslogic_set_voltage_threshold(sdi, (low + high) / 2.0);
                }
                break;
        case SR_CONF_EXTERNAL_CLOCK:
@@ -491,10 +488,10 @@ static int config_set(uint32_t key, GVariant *data,
                devc->clock_edge = idx;
                break;
        default:
-               ret = SR_ERR_NA;
+               return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_list(uint32_t key, GVariant **data,
index adcc246ac41ebe535c70c4c22a749635885975b5..c72daa7f0e9965e7deeee54f04806a806be0ba05 100644 (file)
@@ -488,7 +488,7 @@ 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 idx, ret;
+       int idx;
 
        (void)cg;
 
@@ -497,8 +497,6 @@ static int config_set(uint32_t key, GVariant *data,
 
        devc = sdi->priv;
 
-       ret = SR_OK;
-
        switch (key) {
        case SR_CONF_SAMPLERATE:
                if ((idx = std_u64_idx(data, devc->samplerates, devc->num_samplerates)) < 0)
@@ -510,13 +508,12 @@ static int config_set(uint32_t key, GVariant *data,
                break;
        case SR_CONF_CAPTURE_RATIO:
                devc->capture_ratio = g_variant_get_uint64(data);
-               ret = (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
-               break;
+               return (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
        default:
-               ret = SR_ERR_NA;
+               return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_list(uint32_t key, GVariant **data,
index f7ec7149b93cc14cbadc2de303ad797bffe0195c..7783dec172f679bc0e94b8f56947761354eace39 100644 (file)
@@ -154,7 +154,7 @@ static int check_channel_group(struct dev_context *devc,
 static int config_get(uint32_t key, GVariant **data,
        const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
-       int ret, cg_type;
+       int cg_type;
        unsigned int i;
        struct dev_context *devc;
        const struct scope_config *model;
@@ -168,19 +168,16 @@ static int config_get(uint32_t key, GVariant **data,
        if ((cg_type = check_channel_group(devc, cg)) == CG_INVALID)
                return SR_ERR;
 
-       ret = SR_ERR_NA;
        model = devc->model_config;
        state = devc->model_state;
 
        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][0],
                                      (*model->timebases)[state->timebase][1]);
-               ret = SR_OK;
                break;
        case SR_CONF_NUM_VDIV:
                if (cg_type == CG_NONE) {
@@ -190,12 +187,10 @@ static int config_get(uint32_t key, GVariant **data,
                                if (cg != devc->analog_groups[i])
                                        continue;
                                *data = g_variant_new_int32(model->num_ydivs);
-                               ret = SR_OK;
                                break;
                        }
-
                } else {
-                       ret = SR_ERR_NA;
+                       return SR_ERR_NA;
                }
                break;
        case SR_CONF_VDIV:
@@ -208,25 +203,20 @@ static int config_get(uint32_t key, GVariant **data,
                                *data = g_variant_new("(tt)",
                                                      (*model->vdivs)[state->analog_channels[i].vdiv][0],
                                                      (*model->vdivs)[state->analog_channels[i].vdiv][1]);
-                               ret = SR_OK;
                                break;
                        }
-
                } else {
-                       ret = SR_ERR_NA;
+                       return SR_ERR_NA;
                }
                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:
                if (cg_type == CG_NONE) {
@@ -236,23 +226,20 @@ static int config_get(uint32_t key, GVariant **data,
                                if (cg != devc->analog_groups[i])
                                        continue;
                                *data = g_variant_new_string((*model->coupling_options)[state->analog_channels[i].coupling]);
-                               ret = SR_OK;
                                break;
                        }
-
                } else {
-                       ret = SR_ERR_NA;
+                       return SR_ERR_NA;
                }
                break;
        case SR_CONF_SAMPLERATE:
                *data = g_variant_new_uint64(state->sample_rate);
-               ret = SR_OK;
                break;
        default:
-               ret = SR_ERR_NA;
+               return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_set(uint32_t key, GVariant *data,
index 599cad74279d06466ca73a55b60b8c820b0bc160..5325224e5e8207e7593b5a0c55765e20866be7e2 100644 (file)
@@ -245,7 +245,6 @@ static int config_get(uint32_t key, GVariant **data,
 static int config_set(uint32_t key, GVariant *data,
        const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
-       int ret;
        enum sr_mq mq;
        enum sr_mqflag mq_flags;
        struct dev_context *devc;
@@ -255,7 +254,6 @@ static int config_set(uint32_t key, GVariant *data,
 
        devc = sdi->priv;
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_LIMIT_SAMPLES:
                devc->limit_samples = g_variant_get_uint64(data);
@@ -265,17 +263,15 @@ static int config_set(uint32_t key, GVariant *data,
                mq = g_variant_get_uint32(tuple_child);
                tuple_child = g_variant_get_child_value(data, 1);
                mq_flags = g_variant_get_uint64(tuple_child);
-               ret = hp_3457a_set_mq(sdi, mq, mq_flags);
                g_variant_unref(tuple_child);
-               break;
+               return hp_3457a_set_mq(sdi, mq, mq_flags);
        case SR_CONF_ADC_POWERLINE_CYCLES:
-               ret = hp_3457a_set_nplc(sdi, g_variant_get_double(data));
-               break;
+               return hp_3457a_set_nplc(sdi, g_variant_get_double(data));
        default:
-               ret = SR_ERR_NA;
+               return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_list(uint32_t key, GVariant **data,
index 5f8fc37e3f0644373cebe6d1d36dfef0979e2c4f..ef3ca0d8a77edb18ee06f18233f0a750d394f62c 100644 (file)
@@ -248,11 +248,9 @@ 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;
 
        (void)cg;
 
-       ret = SR_OK;
        devc = sdi->priv;
 
        switch (key) {
@@ -266,35 +264,31 @@ 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)
 {
        uint64_t samplerate, limit_samples, capture_ratio;
-       int ret;
 
        (void)cg;
 
        switch (key) {
        case SR_CONF_LIMIT_SAMPLES:
                limit_samples = g_variant_get_uint64(data);
-               ret = sl2_set_limit_samples(sdi, limit_samples);
-               break;
+               return sl2_set_limit_samples(sdi, limit_samples);
        case SR_CONF_SAMPLERATE:
                samplerate = g_variant_get_uint64(data);
-               ret = sl2_set_samplerate(sdi, samplerate);
-               break;
+               return sl2_set_samplerate(sdi, samplerate);
        case SR_CONF_CAPTURE_RATIO:
                capture_ratio = g_variant_get_uint64(data);
-               ret = sl2_set_capture_ratio(sdi, capture_ratio);
-               break;
+               return sl2_set_capture_ratio(sdi, capture_ratio);
        default:
                return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_list(uint32_t key, GVariant **data,
index 1b92b3cd0cb1111ceb43cef153d86f8defd8cd0c..44c0c29297bb8d1d33a8ce845da3cf224b556443 100644 (file)
@@ -217,7 +217,6 @@ static int config_get(uint32_t key, GVariant **data,
        case SR_CONF_DATALOG:
                /* There really isn't a way to be sure the device is logging. */
                return SR_ERR_NA;
-               break;
        case SR_CONF_SPL_WEIGHT_FREQ:
                if (devc->mqflags & SR_MQFLAG_SPL_FREQ_WEIGHT_A)
                        *data = g_variant_new_string("A");
index b5d73b2382472e5e7896f61a541ff470c3398184..c64882c0bdb9913086bb24cd376b5da2c50e58d6 100644 (file)
@@ -158,27 +158,26 @@ 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_DATALOG:
                if (g_variant_get_boolean(data))
-                       ret = lascar_start_logging(sdi);
+                       return lascar_start_logging(sdi);
                else
-                       ret = lascar_stop_logging(sdi);
+                       return lascar_stop_logging(sdi);
                break;
        case SR_CONF_LIMIT_SAMPLES:
                devc->limit_samples = 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,
index dc6ee2bcd795645bd9b3ec9740a97d506c04c4c2..d1040b19450564c627375ddd05b66b05cf8e4079 100644 (file)
@@ -401,6 +401,7 @@ static int config_list(uint32_t key, GVariant **data,
        default:
                return SR_ERR_NA;
        }
+
        return SR_OK;
 }
 
index f48ad5d344823411cae6d5f2cd3c93187cee7a00..793ec53995be79664750b3be44b26fcd8cf0bb92 100644 (file)
@@ -228,7 +228,6 @@ static int config_get(int key, GVariant **data,
 static int config_set(int key, GVariant *data,
        const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
-       int ret;
        struct dev_context *devc;
        uint64_t num_samples;
        const char *slope;
@@ -239,7 +238,6 @@ static int config_set(int key, GVariant *data,
 
        devc = sdi->priv;
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_SAMPLERATE:
                // FIXME
@@ -248,9 +246,8 @@ static int config_set(int key, GVariant *data,
                num_samples = g_variant_get_uint64(data);
                if (num_samples != 1024) {
                        sr_err("Only 1024 samples are supported.");
-                       ret = SR_ERR_ARG;
-                       break;
-               };
+                       return SR_ERR_ARG;
+               }
                devc->limit_samples = num_samples;
                break;
        case SR_CONF_CAPTURE_RATIO:
@@ -260,8 +257,7 @@ static int config_set(int key, GVariant *data,
 
                if (!slope || !(slope[0] == 'f' || slope[0] == 'r'))
                        sr_err("Invalid trigger slope");
-                       ret = SR_ERR_ARG;
-                       break;
+                       return SR_ERR_ARG;
                }
                devc->trigger_slope = (slope[0] == 'r')
                        ? SLOPE_POSITIVE : SLOPE_NEGATIVE;
@@ -270,8 +266,7 @@ static int config_set(int key, GVariant *data,
                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;
-                       break;
+                       return SR_ERR_ARG;
                }
                trigger_pos = (int)pos;
                devc->trigger_holdoff[0] = trigger_pos & 0xff;
@@ -279,10 +274,10 @@ static int config_set(int key, GVariant *data,
        case SR_CONF_RLE:
                break;
        default:
-               ret = SR_ERR_NA;
+               return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_list(int key, GVariant **data,
index 1ae2adeda381b7e66c9862968ed3719c49b4280c..ebc0ddab85a96bd81ce7f1e416215ead5dd878da 100644 (file)
@@ -321,39 +321,31 @@ static int config_set(uint32_t key, GVariant *data,
 {
        struct dev_context *devc;
        struct sr_modbus_dev_inst *modbus;
-       int ret;
 
        (void)cg;
 
        modbus = sdi->conn;
        devc = sdi->priv;
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_LIMIT_SAMPLES:
        case SR_CONF_LIMIT_MSEC:
-               ret = sr_sw_limits_config_set(&devc->limits, key, data);
-               break;
+               return sr_sw_limits_config_set(&devc->limits, key, data);
        case SR_CONF_ENABLED:
-               ret = maynuo_m97_set_input(modbus, g_variant_get_boolean(data));
-               break;
+               return maynuo_m97_set_input(modbus, g_variant_get_boolean(data));
        case SR_CONF_VOLTAGE_TARGET:
-               ret = maynuo_m97_set_float(modbus, UFIX, g_variant_get_double(data));
-               break;
+               return maynuo_m97_set_float(modbus, UFIX, g_variant_get_double(data));
        case SR_CONF_CURRENT_LIMIT:
-               ret = maynuo_m97_set_float(modbus, IFIX, g_variant_get_double(data));
-               break;
+               return maynuo_m97_set_float(modbus, IFIX, g_variant_get_double(data));
        case SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD:
-               ret = maynuo_m97_set_float(modbus, UMAX, g_variant_get_double(data));
-               break;
+               return maynuo_m97_set_float(modbus, UMAX, g_variant_get_double(data));
        case SR_CONF_OVER_CURRENT_PROTECTION_THRESHOLD:
-               ret = maynuo_m97_set_float(modbus, IMAX, g_variant_get_double(data));
-               break;
+               return maynuo_m97_set_float(modbus, IMAX, g_variant_get_double(data));
        default:
-               ret = SR_ERR_NA;
+               return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_list(uint32_t key, GVariant **data,
index 76184fb2815966ea32cb36517b57ae2b5635d68c..0c5817897499d3de0121d5260ac69e06d6e0cf4f 100644 (file)
@@ -612,7 +612,6 @@ static int config_set(uint32_t key, GVariant *data,
                                return SR_ERR_NA;
                        devc->channel_status[ch_idx].output_current_max = dval;
                        return lps_cmd_ok(sdi->conn, "ISET%d %05.4f", ch_idx+1, dval);
-                       break;
                case SR_CONF_ENABLED:
                        bval = g_variant_get_boolean(data);
                        if (bval == devc->channel_status[ch_idx].output_enabled) /* Nothing to do. */
index db454a9f1a9577f6d627e3dca40c800d68d35238..cdd5074723e2940c6971bcb04b3297a092e6d24e 100644 (file)
@@ -198,6 +198,7 @@ static int config_get(uint32_t key, GVariant **data,
                return SR_ERR_ARG;
 
        devc = sdi->priv;
+
        switch (key) {
        case SR_CONF_SAMPLERATE:
                *data = g_variant_new_uint64(devc->cur_samplerate);
@@ -232,7 +233,6 @@ static int config_set(uint32_t key, GVariant *data,
        struct dev_context *devc;
        uint16_t flag;
        uint64_t tmp_u64;
-       int ret;
        const char *stropt;
 
        (void)cg;
@@ -244,21 +244,19 @@ static int config_set(uint32_t key, GVariant *data,
                tmp_u64 = g_variant_get_uint64(data);
                if (tmp_u64 < samplerates[0] || tmp_u64 > samplerates[1])
                        return SR_ERR_SAMPLERATE;
-               ret = ols_set_samplerate(sdi, g_variant_get_uint64(data));
-               break;
+               return ols_set_samplerate(sdi, g_variant_get_uint64(data));
        case SR_CONF_LIMIT_SAMPLES:
                tmp_u64 = g_variant_get_uint64(data);
                if (tmp_u64 < MIN_NUM_SAMPLES)
                        return SR_ERR;
                devc->limit_samples = tmp_u64;
-               ret = SR_OK;
                break;
        case SR_CONF_CAPTURE_RATIO:
                devc->capture_ratio = g_variant_get_uint64(data);
                if (devc->capture_ratio < 0 || devc->capture_ratio > 100)
-                       ret = SR_ERR;
+                       return SR_ERR;
                else
-                       ret = SR_OK;
+                       return SR_OK;
                break;
        case SR_CONF_EXTERNAL_CLOCK:
                if (g_variant_get_boolean(data)) {
@@ -268,23 +266,21 @@ static int config_set(uint32_t key, GVariant *data,
                        sr_info("Disabled external clock.");
                        devc->flag_reg &= ~FLAG_CLOCK_EXTERNAL;
                }
-               ret = SR_OK;
                break;
        case SR_CONF_PATTERN_MODE:
                stropt = g_variant_get_string(data, NULL);
-               ret = SR_OK;
                flag = 0xffff;
                if (!strcmp(stropt, STR_PATTERN_NONE)) {
                        sr_info("Disabling test modes.");
                        flag = 0x0000;
-               }else if (!strcmp(stropt, STR_PATTERN_INTERNAL)) {
+               } else if (!strcmp(stropt, STR_PATTERN_INTERNAL)) {
                        sr_info("Enabling internal test mode.");
                        flag = FLAG_INTERNAL_TEST_MODE;
                } else if (!strcmp(stropt, STR_PATTERN_EXTERNAL)) {
                        sr_info("Enabling external test mode.");
                        flag = FLAG_EXTERNAL_TEST_MODE;
                } else {
-                       ret = SR_ERR;
+                       return SR_ERR;
                }
                if (flag != 0xffff) {
                        devc->flag_reg &= ~(FLAG_INTERNAL_TEST_MODE | FLAG_EXTERNAL_TEST_MODE);
@@ -299,9 +295,7 @@ static int config_set(uint32_t key, GVariant *data,
                        sr_info("Disabling channel swapping.");
                        devc->flag_reg &= ~FLAG_SWAP_CHANNELS;
                }
-               ret = SR_OK;
                break;
-
        case SR_CONF_RLE:
                if (g_variant_get_boolean(data)) {
                        sr_info("Enabling RLE.");
@@ -310,13 +304,12 @@ static int config_set(uint32_t key, GVariant *data,
                        sr_info("Disabling RLE.");
                        devc->flag_reg &= ~FLAG_RLE;
                }
-               ret = SR_OK;
                break;
        default:
-               ret = SR_ERR_NA;
+               return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_list(uint32_t key, GVariant **data,
index eb86f3a735127dbb119285db0b8fbd9ba9bdc7b1..af3894ba11a329a447d35ab85245bac64f5f160e 100644 (file)
@@ -114,7 +114,7 @@ static int config_get(uint32_t key, GVariant **data,
                return SR_ERR_ARG;
 
        devc = sdi->priv;
-       ret = SR_OK;
+
        switch (key) {
        case SR_CONF_LIMIT_SAMPLES:
                *data = g_variant_new_uint64(devc->limit_samples);
@@ -140,6 +140,8 @@ static int config_get(uint32_t key, GVariant **data,
        case SR_CONF_SPL_MEASUREMENT_RANGE:
                if ((ret = pce_322a_meas_range_get(sdi, &low, &high)) == SR_OK)
                        *data = std_gvar_tuple_u64(low, high);
+               else
+                       return ret;
                break;
        case SR_CONF_POWER_OFF:
                *data = g_variant_new_boolean(FALSE);
@@ -154,20 +156,19 @@ 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, idx;
+       int idx;
 
        (void)cg;
 
        devc = sdi->priv;
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_LIMIT_SAMPLES:
                devc->limit_samples = g_variant_get_uint64(data);
@@ -175,23 +176,20 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
        case SR_CONF_SPL_WEIGHT_FREQ:
                if ((idx = std_str_idx(data, ARRAY_AND_SIZE(weight_freq))) < 0)
                        return SR_ERR_ARG;
-               ret = pce_322a_weight_freq_set(sdi, (weight_freq[idx][0] == 'A') ?
+               return pce_322a_weight_freq_set(sdi, (weight_freq[idx][0] == 'A') ?
                        SR_MQFLAG_SPL_FREQ_WEIGHT_A : SR_MQFLAG_SPL_FREQ_WEIGHT_C);
-               break;
        case SR_CONF_SPL_WEIGHT_TIME:
                if ((idx = std_str_idx(data, ARRAY_AND_SIZE(weight_time))) < 0)
                        return SR_ERR_ARG;
-               ret = pce_322a_weight_time_set(sdi, (weight_time[idx][0] == 'F') ?
+               return pce_322a_weight_time_set(sdi, (weight_time[idx][0] == 'F') ?
                        SR_MQFLAG_SPL_TIME_WEIGHT_F : SR_MQFLAG_SPL_TIME_WEIGHT_S);
-               break;
        case SR_CONF_SPL_MEASUREMENT_RANGE:
                if ((idx = std_u64_tuple_idx(data, ARRAY_AND_SIZE(meas_ranges))) < 0)
                        return SR_ERR_ARG;
-               ret = pce_322a_meas_range_set(sdi, meas_ranges[idx][0], meas_ranges[idx][1]);
-               break;
+               return pce_322a_meas_range_set(sdi, meas_ranges[idx][0], meas_ranges[idx][1]);
        case SR_CONF_POWER_OFF:
                if (g_variant_get_boolean(data))
-                       ret = pce_322a_power_off(sdi);
+                       return pce_322a_power_off(sdi);
                break;
        case SR_CONF_DATA_SOURCE:
                if ((idx = std_str_idx(data, ARRAY_AND_SIZE(data_sources))) < 0)
@@ -199,10 +197,10 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                devc->cur_data_source = idx;
                break;
        default:
-               ret = SR_ERR_NA;
+               return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_list(uint32_t key, GVariant **data,
index 8aca1ed12f844c30cec2aadabbe26013dc116712..9fc0ccffd44ea2d9bcc8994f232302c2df6520c3 100644 (file)
@@ -206,6 +206,7 @@ static int config_get(uint32_t key, GVariant **data,
                return SR_ERR_ARG;
 
        devc = sdi->priv;
+
        switch (key) {
        case SR_CONF_SAMPLERATE:
                *data = g_variant_new_uint64(devc->cur_samplerate);
@@ -243,7 +244,6 @@ static int config_set(uint32_t key, GVariant *data,
        struct dev_context *devc;
        uint16_t flag;
        uint64_t tmp_u64;
-       int ret;
        const char *stropt;
 
        (void)cg;
@@ -255,21 +255,19 @@ static int config_set(uint32_t key, GVariant *data,
                tmp_u64 = g_variant_get_uint64(data);
                if (tmp_u64 < samplerates[0] || tmp_u64 > samplerates[1])
                        return SR_ERR_SAMPLERATE;
-               ret = p_ols_set_samplerate(sdi, g_variant_get_uint64(data));
-               break;
+               return p_ols_set_samplerate(sdi, g_variant_get_uint64(data));
        case SR_CONF_LIMIT_SAMPLES:
                tmp_u64 = g_variant_get_uint64(data);
                if (tmp_u64 < MIN_NUM_SAMPLES)
                        return SR_ERR;
                devc->limit_samples = tmp_u64;
-               ret = SR_OK;
                break;
        case SR_CONF_CAPTURE_RATIO:
                devc->capture_ratio = g_variant_get_uint64(data);
                if (devc->capture_ratio < 0 || devc->capture_ratio > 100)
-                       ret = SR_ERR;
+                       return SR_ERR;
                else
-                       ret = SR_OK;
+                       return SR_OK;
                break;
        case SR_CONF_EXTERNAL_CLOCK:
                if (g_variant_get_boolean(data)) {
@@ -279,23 +277,21 @@ static int config_set(uint32_t key, GVariant *data,
                        sr_info("Disabled external clock.");
                        devc->flag_reg &= ~FLAG_CLOCK_EXTERNAL;
                }
-               ret = SR_OK;
                break;
        case SR_CONF_PATTERN_MODE:
                stropt = g_variant_get_string(data, NULL);
-               ret = SR_OK;
                flag = 0xffff;
                if (!strcmp(stropt, STR_PATTERN_NONE)) {
                        sr_info("Disabling test modes.");
                        flag = 0x0000;
-               }else if (!strcmp(stropt, STR_PATTERN_INTERNAL)) {
+               } else if (!strcmp(stropt, STR_PATTERN_INTERNAL)) {
                        sr_info("Enabling internal test mode.");
                        flag = FLAG_INTERNAL_TEST_MODE;
                } else if (!strcmp(stropt, STR_PATTERN_EXTERNAL)) {
                        sr_info("Enabling external test mode.");
                        flag = FLAG_EXTERNAL_TEST_MODE;
                } else {
-                       ret = SR_ERR;
+                       return SR_ERR;
                }
                if (flag != 0xffff) {
                        devc->flag_reg &= ~(FLAG_INTERNAL_TEST_MODE | FLAG_EXTERNAL_TEST_MODE);
@@ -310,9 +306,7 @@ static int config_set(uint32_t key, GVariant *data,
                        sr_info("Disabling channel swapping.");
                        devc->flag_reg &= ~FLAG_SWAP_CHANNELS;
                }
-               ret = SR_OK;
                break;
-
        case SR_CONF_RLE:
                if (g_variant_get_boolean(data)) {
                        sr_info("Enabling RLE.");
@@ -321,13 +315,12 @@ static int config_set(uint32_t key, GVariant *data,
                        sr_info("Disabling RLE.");
                        devc->flag_reg &= ~FLAG_RLE;
                }
-               ret = SR_OK;
                break;
        default:
-               ret = SR_ERR_NA;
+               return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_list(uint32_t key, GVariant **data,
index 367474d87915465208408e520974eb74ef862e5a..72077d2ed47b830c57233f50432bc28d628fe921 100644 (file)
@@ -632,7 +632,6 @@ static int config_set(uint32_t key, GVariant *data,
                return SR_ERR;
        }
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_LIMIT_FRAMES:
                devc->limit_frames = g_variant_get_uint64(data);
@@ -642,8 +641,7 @@ static int config_set(uint32_t key, GVariant *data,
                        return SR_ERR_ARG;
                g_free(devc->trigger_slope);
                devc->trigger_slope = g_strdup((trigger_slopes[idx][0] == 'r') ? "POS" : "NEG");
-               ret = rigol_ds_config_set(sdi, ":TRIG:EDGE:SLOP %s", devc->trigger_slope);
-               break;
+               return rigol_ds_config_set(sdi, ":TRIG:EDGE:SLOP %s", devc->trigger_slope);
        case SR_CONF_HORIZ_TRIGGERPOS:
                t_dbl = g_variant_get_double(data);
                if (t_dbl < 0.0 || t_dbl > 1.0) {
@@ -655,23 +653,21 @@ static int config_set(uint32_t key, GVariant *data,
                 * need to express this in seconds. */
                t_dbl = -(devc->horiz_triggerpos - 0.5) * devc->timebase * devc->num_timebases;
                g_ascii_formatd(buffer, sizeof(buffer), "%.6f", t_dbl);
-               ret = rigol_ds_config_set(sdi, ":TIM:OFFS %s", buffer);
-               break;
+               return rigol_ds_config_set(sdi, ":TIM:OFFS %s", buffer);
        case SR_CONF_TRIGGER_LEVEL:
                t_dbl = g_variant_get_double(data);
                g_ascii_formatd(buffer, sizeof(buffer), "%.3f", t_dbl);
                ret = rigol_ds_config_set(sdi, ":TRIG:EDGE:LEV %s", buffer);
                if (ret == SR_OK)
                        devc->trigger_level = t_dbl;
-               break;
+               return ret;
        case SR_CONF_TIMEBASE:
                if ((idx = std_u64_tuple_idx(data, devc->timebases, devc->num_timebases)) < 0)
                        return SR_ERR_ARG;
                devc->timebase = (float)devc->timebases[idx][0] / devc->timebases[idx][1];
                g_ascii_formatd(buffer, sizeof(buffer), "%.9f",
                                devc->timebase);
-               ret = rigol_ds_config_set(sdi, ":TIM:SCAL %s", buffer);
-               break;
+               return rigol_ds_config_set(sdi, ":TIM:SCAL %s", buffer);
        case SR_CONF_TRIGGER_SOURCE:
                if ((idx = std_str_idx(data, ARRAY_AND_SIZE(trigger_sources))) < 0)
                        return SR_ERR_ARG;
@@ -689,8 +685,7 @@ static int config_set(uint32_t key, GVariant *data,
                        tmp_str = "CHAN4";
                else
                        tmp_str = (char *)devc->trigger_source;
-               ret = rigol_ds_config_set(sdi, ":TRIG:EDGE:SOUR %s", tmp_str);
-               break;
+               return rigol_ds_config_set(sdi, ":TRIG:EDGE:SOUR %s", tmp_str);
        case SR_CONF_VDIV:
                if (!cg)
                        return SR_ERR_CHANNEL_GROUP;
@@ -759,7 +754,7 @@ static int config_set(uint32_t key, GVariant *data,
                return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_list(uint32_t key, GVariant **data,
index e66d845b9f6d41189fa4dddbaed8bcd517cba7b9..3ee4ea65802df47465b2f25db57c96c84a39e909 100644 (file)
@@ -403,12 +403,10 @@ static int config_get(uint32_t key, GVariant **data,
 {
        struct dev_context *devc;
        struct sr_usb_dev_inst *usb;
-       int ret;
        unsigned int i;
 
        (void)cg;
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_CONN:
                if (!sdi || !sdi->conn)
@@ -436,34 +434,31 @@ static int config_get(uint32_t key, GVariant **data,
                if (!sdi)
                        return SR_ERR;
                devc = sdi->priv;
-               ret = SR_ERR;
                for (i = 0; i < ARRAY_SIZE(volt_thresholds); i++) {
                        if (devc->selected_voltage_range !=
                            volt_thresholds_ranges[i].range)
                                continue;
                        *data = std_gvar_tuple_double(volt_thresholds[i][0], volt_thresholds[i][1]);
-                       ret = SR_OK;
-                       break;
+                       return SR_OK;
                }
-               break;
+               return SR_ERR;
        default:
                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, idx;
+       int idx;
 
        (void)cg;
 
        devc = sdi->priv;
 
-       ret = SR_OK;
        switch (key) {
        case SR_CONF_SAMPLERATE:
                devc->cur_samplerate = g_variant_get_uint64(data);
@@ -473,18 +468,17 @@ static int config_set(uint32_t key, GVariant *data,
                break;
        case SR_CONF_CAPTURE_RATIO:
                devc->capture_ratio = g_variant_get_uint64(data);
-               ret = (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
-               break;
+               return (devc->capture_ratio > 100) ? SR_ERR : SR_OK;
        case SR_CONF_VOLTAGE_THRESHOLD:
                if ((idx = std_double_tuple_idx(data, ARRAY_AND_SIZE(volt_thresholds))) < 0)
                        return SR_ERR_ARG;
                devc->selected_voltage_range = volt_thresholds_ranges[idx].range;
                break;
        default:
-               ret = SR_ERR_NA;
+               return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_list(uint32_t key, GVariant **data,
index 6de714014e2ea0c800b10a02af75857ddbe1905b..6ffc17d4f7ca1d03fcd3e7862d969edb346bad83 100644 (file)
@@ -433,7 +433,6 @@ static int config_set(uint32_t key, GVariant *data,
 {
        struct dev_context *devc;
        double d;
-       int ret;
 
        if (!sdi)
                return SR_ERR_ARG;
@@ -446,66 +445,66 @@ static int config_set(uint32_t key, GVariant *data,
        switch (key) {
        case SR_CONF_ENABLED:
                if (g_variant_get_boolean(data))
-                       ret = scpi_cmd(sdi, devc->device->commands,
+                       return scpi_cmd(sdi, devc->device->commands,
                                        SCPI_CMD_SET_OUTPUT_ENABLE);
                else
-                       ret = scpi_cmd(sdi, devc->device->commands,
+                       return scpi_cmd(sdi, devc->device->commands,
                                        SCPI_CMD_SET_OUTPUT_DISABLE);
                break;
        case SR_CONF_VOLTAGE_TARGET:
                d = g_variant_get_double(data);
-               ret = scpi_cmd(sdi, devc->device->commands,
+               return scpi_cmd(sdi, devc->device->commands,
                                SCPI_CMD_SET_VOLTAGE_TARGET, d);
                break;
        case SR_CONF_OUTPUT_FREQUENCY_TARGET:
                d = g_variant_get_double(data);
-               ret = scpi_cmd(sdi, devc->device->commands,
+               return scpi_cmd(sdi, devc->device->commands,
                                SCPI_CMD_SET_FREQUENCY_TARGET, d);
                break;
        case SR_CONF_CURRENT_LIMIT:
                d = g_variant_get_double(data);
-               ret = scpi_cmd(sdi, devc->device->commands,
+               return scpi_cmd(sdi, devc->device->commands,
                                SCPI_CMD_SET_CURRENT_LIMIT, d);
                break;
        case SR_CONF_OVER_VOLTAGE_PROTECTION_ENABLED:
                if (g_variant_get_boolean(data))
-                       ret = scpi_cmd(sdi, devc->device->commands,
+                       return scpi_cmd(sdi, devc->device->commands,
                                        SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_ENABLE);
                else
-                       ret = scpi_cmd(sdi, devc->device->commands,
+                       return scpi_cmd(sdi, devc->device->commands,
                                        SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_DISABLE);
                break;
        case SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD:
                d = g_variant_get_double(data);
-               ret = scpi_cmd(sdi, devc->device->commands,
+               return scpi_cmd(sdi, devc->device->commands,
                                SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_THRESHOLD, d);
                break;
        case SR_CONF_OVER_CURRENT_PROTECTION_ENABLED:
                if (g_variant_get_boolean(data))
-                       ret = scpi_cmd(sdi, devc->device->commands,
+                       return scpi_cmd(sdi, devc->device->commands,
                                        SCPI_CMD_SET_OVER_CURRENT_PROTECTION_ENABLE);
                else
-                       ret = scpi_cmd(sdi, devc->device->commands,
+                       return scpi_cmd(sdi, devc->device->commands,
                                        SCPI_CMD_SET_OVER_CURRENT_PROTECTION_DISABLE);
                break;
        case SR_CONF_OVER_CURRENT_PROTECTION_THRESHOLD:
                d = g_variant_get_double(data);
-               ret = scpi_cmd(sdi, devc->device->commands,
+               return scpi_cmd(sdi, devc->device->commands,
                                SCPI_CMD_SET_OVER_CURRENT_PROTECTION_THRESHOLD, d);
                break;
        case SR_CONF_OVER_TEMPERATURE_PROTECTION:
                if (g_variant_get_boolean(data))
-                       ret = scpi_cmd(sdi, devc->device->commands,
+                       return scpi_cmd(sdi, devc->device->commands,
                                        SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_ENABLE);
                else
-                       ret = scpi_cmd(sdi, devc->device->commands,
+                       return scpi_cmd(sdi, devc->device->commands,
                                        SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_DISABLE);
                break;
        default:
-               ret = SR_ERR_NA;
+               return SR_ERR_NA;
        }
 
-       return ret;
+       return SR_OK;
 }
 
 static int config_list(uint32_t key, GVariant **data,