diff --git a/src/hardware/agilent-dmm/api.c b/src/hardware/agilent-dmm/api.c index 7bafabc2..b5ba7ae2 100644 --- a/src/hardware/agilent-dmm/api.c +++ b/src/hardware/agilent-dmm/api.c @@ -166,10 +166,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) { - sr_err("sdi->priv was NULL."); - return SR_ERR_BUG; - } + devc = sdi->priv; switch (key) { case SR_CONF_LIMIT_MSEC: diff --git a/src/hardware/appa-55ii/api.c b/src/hardware/appa-55ii/api.c index 0574a487..09b24cb2 100644 --- a/src/hardware/appa-55ii/api.c +++ b/src/hardware/appa-55ii/api.c @@ -149,10 +149,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) { - sr_err("sdi->priv was NULL."); - return SR_ERR_BUG; - } + devc = sdi->priv; switch (key) { case SR_CONF_LIMIT_SAMPLES: diff --git a/src/hardware/brymen-bm86x/api.c b/src/hardware/brymen-bm86x/api.c index 345532e7..afed5771 100644 --- a/src/hardware/brymen-bm86x/api.c +++ b/src/hardware/brymen-bm86x/api.c @@ -184,10 +184,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) { - sr_err("sdi->priv was NULL."); - return SR_ERR_BUG; - } + devc = sdi->priv; return sr_sw_limits_config_set(&devc->sw_limits, key, data); } diff --git a/src/hardware/brymen-dmm/api.c b/src/hardware/brymen-dmm/api.c index e9e534df..4d70e9ed 100644 --- a/src/hardware/brymen-dmm/api.c +++ b/src/hardware/brymen-dmm/api.c @@ -137,10 +137,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) { - sr_err("sdi->priv was NULL."); - return SR_ERR_BUG; - } + devc = sdi->priv; return sr_sw_limits_config_set(&devc->sw_limits, key, data); } diff --git a/src/hardware/cem-dt-885x/api.c b/src/hardware/cem-dt-885x/api.c index f9ecc7cc..e31eaf2a 100644 --- a/src/hardware/cem-dt-885x/api.c +++ b/src/hardware/cem-dt-885x/api.c @@ -217,10 +217,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) { - sr_err("sdi->priv was NULL."); - return SR_ERR_BUG; - } + devc = sdi->priv; ret = SR_OK; switch (key) { diff --git a/src/hardware/chronovu-la/api.c b/src/hardware/chronovu-la/api.c index ae326772..932c9430 100644 --- a/src/hardware/chronovu-la/api.c +++ b/src/hardware/chronovu-la/api.c @@ -351,8 +351,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) - return SR_ERR_BUG; + devc = sdi->priv; switch (key) { case SR_CONF_SAMPLERATE: diff --git a/src/hardware/colead-slm/api.c b/src/hardware/colead-slm/api.c index 33f27614..ac13da99 100644 --- a/src/hardware/colead-slm/api.c +++ b/src/hardware/colead-slm/api.c @@ -102,10 +102,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) { - sr_err("sdi->priv was NULL."); - return SR_ERR_BUG; - } + devc = sdi->priv; return sr_sw_limits_config_set(&devc->limits, key, data); } diff --git a/src/hardware/fluke-dmm/api.c b/src/hardware/fluke-dmm/api.c index 0b2f7ffb..61da487b 100644 --- a/src/hardware/fluke-dmm/api.c +++ b/src/hardware/fluke-dmm/api.c @@ -194,10 +194,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) { - sr_err("sdi->priv was NULL."); - return SR_ERR_BUG; - } + devc = sdi->priv; switch (key) { case SR_CONF_LIMIT_MSEC: diff --git a/src/hardware/gmc-mh-1x-2x/protocol.c b/src/hardware/gmc-mh-1x-2x/protocol.c index 1607bfa4..e116244e 100644 --- a/src/hardware/gmc-mh-1x-2x/protocol.c +++ b/src/hardware/gmc-mh-1x-2x/protocol.c @@ -1519,10 +1519,7 @@ SR_PRIV int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *s if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) { - sr_err("sdi->priv was NULL."); - return SR_ERR_BUG; - } + devc = sdi->priv; switch (key) { case SR_CONF_POWER_OFF: diff --git a/src/hardware/gwinstek-gds-800/api.c b/src/hardware/gwinstek-gds-800/api.c index 57ca4fad..4c5e896f 100644 --- a/src/hardware/gwinstek-gds-800/api.c +++ b/src/hardware/gwinstek-gds-800/api.c @@ -148,12 +148,14 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd (void)cg; - if (!sdi || !(devc = sdi->priv)) + if (!sdi) return SR_ERR_ARG; if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; + devc = sdi->priv; + switch (key) { case SR_CONF_LIMIT_FRAMES: devc->frame_limit = g_variant_get_uint64(data); diff --git a/src/hardware/hameg-hmo/api.c b/src/hardware/hameg-hmo/api.c index b89de8d8..afe64891 100644 --- a/src/hardware/hameg-hmo/api.c +++ b/src/hardware/hameg-hmo/api.c @@ -318,9 +318,11 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd double tmp_d; gboolean update_sample_rate; - if (!sdi || !(devc = sdi->priv)) + if (!sdi) return SR_ERR_ARG; + devc = sdi->priv; + if ((cg_type = check_channel_group(devc, cg)) == CG_INVALID) return SR_ERR; diff --git a/src/hardware/kern-scale/api.c b/src/hardware/kern-scale/api.c index 432f3daa..6ec40a62 100644 --- a/src/hardware/kern-scale/api.c +++ b/src/hardware/kern-scale/api.c @@ -125,8 +125,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) - return SR_ERR_BUG; + devc = sdi->priv; return sr_sw_limits_config_set(&devc->limits, key, data); } diff --git a/src/hardware/link-mso19/api.c b/src/hardware/link-mso19/api.c index 137deae6..f6353830 100644 --- a/src/hardware/link-mso19/api.c +++ b/src/hardware/link-mso19/api.c @@ -284,6 +284,7 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi, double pos; (void)cg; + devc = sdi->priv; if (sdi->status != SR_ST_ACTIVE) diff --git a/src/hardware/norma-dmm/api.c b/src/hardware/norma-dmm/api.c index 8ca269c5..78011143 100644 --- a/src/hardware/norma-dmm/api.c +++ b/src/hardware/norma-dmm/api.c @@ -192,10 +192,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) { - sr_err("sdi->priv was NULL."); - return SR_ERR_BUG; - } + devc = sdi->priv; return sr_sw_limits_config_set(&devc->limits, key, data); } diff --git a/src/hardware/rigol-ds/api.c b/src/hardware/rigol-ds/api.c index 7f45e187..c380c330 100644 --- a/src/hardware/rigol-ds/api.c +++ b/src/hardware/rigol-ds/api.c @@ -632,8 +632,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd const char *tmp_str; char buffer[16]; - if (!(devc = sdi->priv)) - return SR_ERR_ARG; + devc = sdi->priv; if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; diff --git a/src/hardware/serial-dmm/api.c b/src/hardware/serial-dmm/api.c index 9007789c..a272cca2 100644 --- a/src/hardware/serial-dmm/api.c +++ b/src/hardware/serial-dmm/api.c @@ -151,10 +151,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) { - sr_err("sdi->priv was NULL."); - return SR_ERR_BUG; - } + devc = sdi->priv; return sr_sw_limits_config_set(&devc->limits, key, data); } diff --git a/src/hardware/teleinfo/api.c b/src/hardware/teleinfo/api.c index 9e64caae..4bccde01 100644 --- a/src/hardware/teleinfo/api.c +++ b/src/hardware/teleinfo/api.c @@ -138,10 +138,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) { - sr_err("sdi->priv was NULL."); - return SR_ERR_BUG; - } + devc = sdi->priv; return sr_sw_limits_config_set(&devc->sw_limits, key, data); } diff --git a/src/hardware/zeroplus-logic-cube/api.c b/src/hardware/zeroplus-logic-cube/api.c index 2207e3da..6a593027 100644 --- a/src/hardware/zeroplus-logic-cube/api.c +++ b/src/hardware/zeroplus-logic-cube/api.c @@ -380,10 +380,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) { - sr_err("%s: sdi->priv was NULL", __func__); - return SR_ERR_ARG; - } + devc = sdi->priv; switch (key) { case SR_CONF_SAMPLERATE: diff --git a/src/hwdriver.c b/src/hwdriver.c index 0c668e05..7e16b82a 100644 --- a/src/hwdriver.c +++ b/src/hwdriver.c @@ -722,7 +722,8 @@ SR_API int sr_config_get(const struct sr_dev_driver *driver, /** * Set value of a configuration key in a device instance. * - * @param[in] sdi The device instance. + * @param[in] sdi The device instance. Must not be NULL. sdi->driver and + * sdi->priv must not be NULL either. * @param[in] cg The channel group on the device for which to list the * values, or NULL. * @param[in] key The configuration key (SR_CONF_*). @@ -746,7 +747,7 @@ SR_API int sr_config_set(const struct sr_dev_inst *sdi, g_variant_ref_sink(data); - if (!sdi || !sdi->driver || !data) + if (!sdi || !sdi->driver || !sdi->priv || !data) ret = SR_ERR; else if (!sdi->driver->config_set) ret = SR_ERR_ARG;