yokogawa-dlm: fix several compiler warnings (assignment, memory)
Check pointers' validity before dereferencing them. Release partially allocated memory in an error path. Remove an assignment which never took effect. This was reported by clang's scan-build.
This commit is contained in:
parent
2da5c95f3d
commit
93b5cd6919
|
@ -164,6 +164,8 @@ static int check_channel_group(struct dev_context *devc,
|
||||||
{
|
{
|
||||||
const struct scope_config *model;
|
const struct scope_config *model;
|
||||||
|
|
||||||
|
if (!devc)
|
||||||
|
return CG_INVALID;
|
||||||
model = devc->model_config;
|
model = devc->model_config;
|
||||||
|
|
||||||
if (!cg)
|
if (!cg)
|
||||||
|
@ -284,8 +286,6 @@ static int config_set(uint32_t key, GVariant *data,
|
||||||
state = devc->model_state;
|
state = devc->model_state;
|
||||||
update_sample_rate = FALSE;
|
update_sample_rate = FALSE;
|
||||||
|
|
||||||
ret = SR_ERR_NA;
|
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_LIMIT_FRAMES:
|
case SR_CONF_LIMIT_FRAMES:
|
||||||
devc->frame_limit = g_variant_get_uint64(data);
|
devc->frame_limit = g_variant_get_uint64(data);
|
||||||
|
@ -409,6 +409,8 @@ static int config_list(uint32_t key, GVariant **data,
|
||||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(dlm_trigger_slopes));
|
*data = g_variant_new_strv(ARRAY_AND_SIZE(dlm_trigger_slopes));
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
case SR_CONF_NUM_HDIV:
|
case SR_CONF_NUM_HDIV:
|
||||||
|
if (!model)
|
||||||
|
return SR_ERR_ARG;
|
||||||
*data = g_variant_new_uint32(model->num_xdivs);
|
*data = g_variant_new_uint32(model->num_xdivs);
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -777,9 +777,13 @@ SR_PRIV int dlm_device_init(struct sr_dev_inst *sdi, int model_index)
|
||||||
|
|
||||||
devc->analog_groups = g_malloc0(sizeof(struct sr_channel_group*) *
|
devc->analog_groups = g_malloc0(sizeof(struct sr_channel_group*) *
|
||||||
scope_models[model_index].analog_channels);
|
scope_models[model_index].analog_channels);
|
||||||
|
|
||||||
devc->digital_groups = g_malloc0(sizeof(struct sr_channel_group*) *
|
devc->digital_groups = g_malloc0(sizeof(struct sr_channel_group*) *
|
||||||
scope_models[model_index].pods);
|
scope_models[model_index].pods);
|
||||||
|
if (!devc->analog_groups || !devc->digital_groups) {
|
||||||
|
g_free(devc->analog_groups);
|
||||||
|
g_free(devc->digital_groups);
|
||||||
|
return SR_ERR_MALLOC;
|
||||||
|
}
|
||||||
|
|
||||||
/* Add analog channels, each in its own group. */
|
/* Add analog channels, each in its own group. */
|
||||||
for (i = 0; i < scope_models[model_index].analog_channels; i++) {
|
for (i = 0; i < scope_models[model_index].analog_channels; i++) {
|
||||||
|
|
Loading…
Reference in New Issue