aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2016-05-14 16:11:53 +0200
committerUwe Hermann <uwe@hermann-uwe.de>2016-05-17 01:12:56 +0200
commit4d399734b4ec7affb58c5881ea1b8d88eaa57d53 (patch)
treef636089b18ee533636b3fd6835cf9274866e4885
parent709468baf7626b162b5559c101516289d9bbb258 (diff)
config_list: Don't check for sdi->priv != NULL.
If sdi is != NULL, the backend ensures that sdi->priv is also != NULL. Almost all drivers were relying on this already.
-rw-r--r--src/hardware/chronovu-la/api.c3
-rw-r--r--src/hardware/fx2lafw/api.c2
-rw-r--r--src/hardware/hameg-hmo/api.c3
-rw-r--r--src/hardware/korad-kaxxxxp/api.c1
-rw-r--r--src/hardware/motech-lps-30x/api.c2
-rw-r--r--src/hardware/rigol-ds/api.c3
-rw-r--r--src/hwdriver.c12
-rw-r--r--src/lcr/es51919.c1
8 files changed, 17 insertions, 10 deletions
diff --git a/src/hardware/chronovu-la/api.c b/src/hardware/chronovu-la/api.c
index b6c3af4..0508250 100644
--- a/src/hardware/chronovu-la/api.c
+++ b/src/hardware/chronovu-la/api.c
@@ -399,8 +399,9 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
devopts, ARRAY_SIZE(devopts), sizeof(uint32_t));
break;
case SR_CONF_SAMPLERATE:
- if (!sdi || !sdi->priv || !(devc = sdi->priv))
+ if (!sdi)
return SR_ERR_BUG;
+ devc = sdi->priv;
cv_fill_samplerates_if_needed(sdi);
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"),
diff --git a/src/hardware/fx2lafw/api.c b/src/hardware/fx2lafw/api.c
index 08fbbcd..54db1f3 100644
--- a/src/hardware/fx2lafw/api.c
+++ b/src/hardware/fx2lafw/api.c
@@ -740,8 +740,6 @@ static int config_list(uint32_t key, GVariant **data,
*data = g_variant_builder_end(&gvb);
break;
case SR_CONF_SAMPLERATE:
- if (!sdi->priv)
- return SR_ERR_ARG;
devc = sdi->priv;
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"), devc->samplerates,
diff --git a/src/hardware/hameg-hmo/api.c b/src/hardware/hameg-hmo/api.c
index 4b50b7a..29dbe91 100644
--- a/src/hardware/hameg-hmo/api.c
+++ b/src/hardware/hameg-hmo/api.c
@@ -487,7 +487,8 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
struct dev_context *devc = NULL;
const struct scope_config *model = NULL;
- if (sdi && (devc = sdi->priv)) {
+ if (sdi) {
+ devc = sdi->priv;
if ((cg_type = check_channel_group(devc, cg)) == CG_INVALID)
return SR_ERR;
diff --git a/src/hardware/korad-kaxxxxp/api.c b/src/hardware/korad-kaxxxxp/api.c
index 19daff8..e008cfe 100644
--- a/src/hardware/korad-kaxxxxp/api.c
+++ b/src/hardware/korad-kaxxxxp/api.c
@@ -288,7 +288,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)
{
-
struct dev_context *devc;
GVariant *gvar;
GVariantBuilder gvb;
diff --git a/src/hardware/motech-lps-30x/api.c b/src/hardware/motech-lps-30x/api.c
index 57bc1d2..57befbf 100644
--- a/src/hardware/motech-lps-30x/api.c
+++ b/src/hardware/motech-lps-30x/api.c
@@ -700,7 +700,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t));
return SR_OK;
case SR_CONF_DEVICE_OPTIONS:
- if (sdi != NULL)
+ if (sdi)
break;
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t));
diff --git a/src/hardware/rigol-ds/api.c b/src/hardware/rigol-ds/api.c
index a88d1ba..e743608 100644
--- a/src/hardware/rigol-ds/api.c
+++ b/src/hardware/rigol-ds/api.c
@@ -805,8 +805,9 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
}
/* Every other option requires a valid device instance. */
- if (!sdi || !(devc = sdi->priv))
+ if (!sdi)
return SR_ERR_ARG;
+ devc = sdi->priv;
/* If a channel group is specified, it must be a valid one. */
if (cg && !g_slist_find(sdi->channel_groups, cg)) {
diff --git a/src/hwdriver.c b/src/hwdriver.c
index fafd93f..6758f6a 100644
--- a/src/hwdriver.c
+++ b/src/hwdriver.c
@@ -710,8 +710,10 @@ SR_API int sr_config_get(const struct sr_dev_driver *driver,
if (check_key(driver, sdi, cg, key, SR_CONF_GET, NULL) != SR_OK)
return SR_ERR_ARG;
- if (sdi && !sdi->priv)
+ if (sdi && !sdi->priv) {
+ sr_err("Can't get config (sdi != NULL, sdi->priv == NULL).");
return SR_ERR;
+ }
if ((ret = driver->config_get(key, data, sdi, cg)) == SR_OK) {
log_key(sdi, cg, key, SR_CONF_GET, *data);
@@ -793,9 +795,11 @@ SR_API int sr_config_commit(const struct sr_dev_inst *sdi)
/**
* List all possible values for a configuration key.
*
- * @param[in] driver The sr_dev_driver struct to query.
+ * @param[in] driver The sr_dev_driver struct to query. Must not be NULL.
* @param[in] sdi (optional) If the key is specific to a device, this must
* contain a pointer to the struct sr_dev_inst to be checked.
+ * Otherwise it must be NULL. If sdi is != NULL, sdi->priv must
+ * also be != NULL.
* @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_*).
@@ -828,6 +832,10 @@ SR_API int sr_config_list(const struct sr_dev_driver *driver,
if (check_key(driver, sdi, cg, key, SR_CONF_LIST, NULL) != SR_OK)
return SR_ERR_ARG;
}
+ if (sdi && !sdi->priv) {
+ sr_err("Can't list config (sdi != NULL, sdi->priv == NULL).");
+ return SR_ERR;
+ }
if ((ret = driver->config_list(key, data, sdi, cg)) == SR_OK) {
log_key(sdi, cg, key, SR_CONF_LIST, *data);
g_variant_ref_sink(*data);
diff --git a/src/lcr/es51919.c b/src/lcr/es51919.c
index f1e27ac..3b32df1 100644
--- a/src/lcr/es51919.c
+++ b/src/lcr/es51919.c
@@ -894,7 +894,6 @@ SR_PRIV int es51919_serial_config_list(uint32_t key, GVariant **data,
*data = g_variant_new_strv(models, ARRAY_SIZE(models));
break;
default:
- sr_spew("%s: Unsupported key %u", __func__, key);
return SR_ERR_NA;
}