If sdi is != NULL, the backend ensures that sdi->priv is also != NULL.
Almost all drivers were relying on this already.
devopts, ARRAY_SIZE(devopts), sizeof(uint32_t));
break;
case SR_CONF_SAMPLERATE:
devopts, ARRAY_SIZE(devopts), sizeof(uint32_t));
break;
case SR_CONF_SAMPLERATE:
- if (!sdi || !sdi->priv || !(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"),
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"),
*data = g_variant_builder_end(&gvb);
break;
case SR_CONF_SAMPLERATE:
*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,
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,
struct dev_context *devc = NULL;
const struct scope_config *model = NULL;
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;
if ((cg_type = check_channel_group(devc, cg)) == CG_INVALID)
return SR_ERR;
static int config_list(uint32_t key, GVariant **data,
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
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;
struct dev_context *devc;
GVariant *gvar;
GVariantBuilder gvb;
scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t));
return SR_OK;
case SR_CONF_DEVICE_OPTIONS:
scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t));
return SR_OK;
case SR_CONF_DEVICE_OPTIONS:
break;
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t));
break;
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t));
}
/* Every other option requires a valid device instance. */
}
/* Every other option requires a valid device instance. */
- if (!sdi || !(devc = sdi->priv))
/* If a channel group is specified, it must be a valid one. */
if (cg && !g_slist_find(sdi->channel_groups, cg)) {
/* If a channel group is specified, it must be a valid one. */
if (cg && !g_slist_find(sdi->channel_groups, cg)) {
if (check_key(driver, sdi, cg, key, SR_CONF_GET, NULL) != SR_OK)
return SR_ERR_ARG;
if (check_key(driver, sdi, cg, key, SR_CONF_GET, NULL) != SR_OK)
return SR_ERR_ARG;
+ if (sdi && !sdi->priv) {
+ sr_err("Can't get config (sdi != NULL, sdi->priv == NULL).");
if ((ret = driver->config_get(key, data, sdi, cg)) == SR_OK) {
log_key(sdi, cg, key, SR_CONF_GET, *data);
if ((ret = driver->config_get(key, data, sdi, cg)) == SR_OK) {
log_key(sdi, cg, key, SR_CONF_GET, *data);
/**
* List all possible values for a configuration key.
*
/**
* 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.
* @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_*).
* @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_LIST, NULL) != SR_OK)
return SR_ERR_ARG;
}
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);
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);
*data = g_variant_new_strv(models, ARRAY_SIZE(models));
break;
default:
*data = g_variant_new_strv(models, ARRAY_SIZE(models));
break;
default:
- sr_spew("%s: Unsupported key %u", __func__, key);