config_set(): Don't check for sdi->priv != NULL.
Instead, have the backend check that sdi->priv is not NULL (which many drivers have been assuming already anyway).
This commit is contained in:
parent
e5b7eef797
commit
b0baddef56
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue