If sdi is != NULL, the backend ensures that sdi->priv is also != NULL.
Almost all drivers were relying on this already.
*data = g_variant_new_string(str);
break;
case SR_CONF_SAMPLERATE:
- if (!sdi || !(devc = sdi->priv))
+ if (!sdi)
return SR_ERR_BUG;
+ devc = sdi->priv;
*data = g_variant_new_uint64(devc->cur_samplerate);
break;
default:
(void)cg;
- if (!sdi || !(devc = sdi->priv))
+ if (!sdi)
return SR_ERR_ARG;
+ devc = sdi->priv;
+
ret = SR_OK;
switch (key) {
case SR_CONF_LIMIT_SAMPLES:
(void)cg;
- if (!sdi || !(devc = sdi->priv))
+ if (!sdi)
return SR_ERR_ARG;
+ devc = sdi->priv;
+
switch (key) {
case SR_CONF_SAMPLERATE:
*data = g_variant_new_uint64(devc->sample_rate);
const struct scope_config *model;
struct scope_state *state;
- 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;
(void)cg;
+ if (!sdi)
+ return SR_ERR_ARG;
+
+ devc = sdi->priv;
+
switch (key) {
case SR_CONF_SAMPLERATE:
- if (sdi) {
- devc = sdi->priv;
- *data = g_variant_new_uint64(devc->cur_rate);
- } else
- return SR_ERR;
+ *data = g_variant_new_uint64(devc->cur_rate);
break;
default:
return SR_ERR_NA;
int idx = -1;
unsigned i;
- 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)) {
sr_err("Invalid channel group specified.");
const struct scope_config *model;
struct scope_state *state;
- 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;
/**
* Query value of a configuration key at the given driver or device instance.
*
- * @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.
+ * 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_*).
if (check_key(driver, sdi, cg, key, SR_CONF_GET, NULL) != SR_OK)
return SR_ERR_ARG;
+ if (sdi && !sdi->priv)
+ return SR_ERR;
+
if ((ret = driver->config_get(key, data, sdi, cg)) == SR_OK) {
log_key(sdi, cg, key, SR_CONF_GET, *data);
/* Got a floating reference from the driver. Sink it here,
(void)cg;
- if (!(devc = sdi->priv))
- return SR_ERR_BUG;
+ devc = sdi->priv;
switch (key) {
case SR_CONF_OUTPUT_FREQUENCY:
*data = g_variant_new_string(models[devc->model]);
break;
default:
- sr_spew("%s: Unsupported key %u", __func__, key);
return SR_ERR_NA;
}