]> sigrok.org Git - libsigrok.git/commitdiff
config_set(): Don't check for sdi->priv != NULL.
authorUwe Hermann <redacted>
Sat, 14 May 2016 13:25:19 +0000 (15:25 +0200)
committerUwe Hermann <redacted>
Mon, 16 May 2016 23:12:56 +0000 (01:12 +0200)
Instead, have the backend check that sdi->priv is not NULL (which
many drivers have been assuming already anyway).

19 files changed:
src/hardware/agilent-dmm/api.c
src/hardware/appa-55ii/api.c
src/hardware/brymen-bm86x/api.c
src/hardware/brymen-dmm/api.c
src/hardware/cem-dt-885x/api.c
src/hardware/chronovu-la/api.c
src/hardware/colead-slm/api.c
src/hardware/fluke-dmm/api.c
src/hardware/gmc-mh-1x-2x/protocol.c
src/hardware/gwinstek-gds-800/api.c
src/hardware/hameg-hmo/api.c
src/hardware/kern-scale/api.c
src/hardware/link-mso19/api.c
src/hardware/norma-dmm/api.c
src/hardware/rigol-ds/api.c
src/hardware/serial-dmm/api.c
src/hardware/teleinfo/api.c
src/hardware/zeroplus-logic-cube/api.c
src/hwdriver.c

index 7bafabc2cf6d33953c3d4a0162732ce7853d3aac..b5ba7ae2e9851134b9561ef9ce4d4cdd5c25a59f 100644 (file)
@@ -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:
index 0574a487d7373bd9f11534e11cd3150147aa568b..09b24cb2d78f7ed9a71516c59a3fb3eea6b29900 100644 (file)
@@ -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:
index 345532e734b6ef981a3fc8e9646e8b6ccd6b3045..afed5771b7062b92be643a9d8d7d290b6c2e4d90 100644 (file)
@@ -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);
 }
index e9e534dfcede044e9014d552aea44d6b6889f0ab..4d70e9edb8cd98dd399bd8b85406d25a7845d3eb 100644 (file)
@@ -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);
 }
index f9ecc7cc3484c6438fe3c5b40db74ba5cfcf829f..e31eaf2af190f5a8af39e334caa337c6addeedcd 100644 (file)
@@ -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) {
index ae32677229677e3d898ed5e1e4f63f8cf835ec11..932c9430039b306a0ecf8b08a582614a8bf57f3f 100644 (file)
@@ -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:
index 33f27614a7e26add75977b78015d622a449fbda7..ac13da99d764f560325bb31615ad1b716d2320fd 100644 (file)
@@ -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);
 }
index 0b2f7ffb0363efdf58dcebeeebb816d08b3ec62b..61da487b629ba7a5d05a62a4367c59c19b225dbe 100644 (file)
@@ -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:
index 1607bfa430adf632379a77d56344a110bb0a626e..e116244e0c448401ad53c42d05c10c12db942d24 100644 (file)
@@ -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:
index 57ca4fad571101b4223931922be7173a469e1bc1..4c5e896f09e9e5fb30954fdae37127e7be30ccff 100644 (file)
@@ -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);
index b89de8d8a096a393b07cf15f8c4bbd8f3b23435c..afe648911a06f4e2e106bf228ac45a5935fa3412 100644 (file)
@@ -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;
 
index 432f3daa6a3c9db4ac3128df7198f8dc91d73152..6ec40a626642bd0338b9225fd658756a41483b3b 100644 (file)
@@ -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);
 }
index 137deae66477ee35007b57fa831f30d170a32475..f635383034b81f43862fb976564b574031e4e0e5 100644 (file)
@@ -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)
index 8ca269c579310cea30da894359f3daeffbc40872..780111432fda09a4125e0d7a146af619823a007c 100644 (file)
@@ -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);
 }
index 7f45e1874173601129d4eeb1ae3a0b5edc1fb82e..c380c330db11d835164dfd24f382d6d368c178f4 100644 (file)
@@ -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;
index 9007789cdc5ee1558aca150607de38a3570392d8..a272cca29b8495e7dfc2af7b4ca3c4691faccda0 100644 (file)
@@ -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);
 }
index 9e64caaed231586ac831b6b1a9223a832a149407..4bccde017a8522cbb8c8a0c8928da54973dea7c9 100644 (file)
@@ -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);
 }
index 2207e3da19e6f5a9ed94e7ec0ecd64a8c1df4922..6a593027fba5d472f33d9f5999fd69054d8aa8a5 100644 (file)
@@ -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:
index 0c668e059e36dc4be51598fccc5fec0f9a9cc987..7e16b82a9cecd2aaca78ead54f4456bea77c56bc 100644 (file)
@@ -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;