hameg-hmo: fix several compiler warnings (assignments, memory)

Silence warnings about assigned values that never get used, potential
NULL deference, and potential memory leaks.

This was reported by clang's scan-build.
This commit is contained in:
Gerhard Sittig 2018-02-09 18:57:49 +01:00 committed by Uwe Hermann
parent 56e9672b11
commit b0e80e9aa9
2 changed files with 10 additions and 3 deletions

View File

@ -246,8 +246,6 @@ static int config_set(uint32_t key, GVariant *data,
state = devc->model_state;
update_sample_rate = FALSE;
ret = SR_ERR_NA;
switch (key) {
case SR_CONF_LIMIT_FRAMES:
devc->frame_limit = g_variant_get_uint64(data);
@ -380,6 +378,8 @@ static int config_list(uint32_t key, GVariant **data,
case SR_CONF_COUPLING:
if (!cg)
return SR_ERR_CHANNEL_GROUP;
if (!model)
return SR_ERR_ARG;
*data = g_variant_new_strv(*model->coupling_options, model->num_coupling_options);
break;
case SR_CONF_TRIGGER_SOURCE:
@ -400,6 +400,8 @@ static int config_list(uint32_t key, GVariant **data,
case SR_CONF_VDIV:
if (!cg)
return SR_ERR_CHANNEL_GROUP;
if (!model)
return SR_ERR_ARG;
*data = std_gvar_tuple_array(*model->vdivs, model->num_vdivs);
break;
default:
@ -552,6 +554,7 @@ static int hmo_setup_channels(const struct sr_dev_inst *sdi)
setup_changed = TRUE;
break;
default:
g_free(pod_enabled);
return SR_ERR;
}
}

View File

@ -687,9 +687,13 @@ SR_PRIV int hmo_init_device(struct sr_dev_inst *sdi)
devc->analog_groups = g_malloc0(sizeof(struct sr_channel_group*) *
scope_models[model_index].analog_channels);
devc->digital_groups = g_malloc0(sizeof(struct sr_channel_group*) *
scope_models[model_index].digital_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. */
for (i = 0; i < scope_models[model_index].analog_channels; i++) {