Silence warnings about assigned values that never get used, potential
NULL deference, and potential memory leaks.
This was reported by clang's scan-build.
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);
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:
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:
setup_changed = TRUE;
break;
default:
+ g_free(pod_enabled);
return SR_ERR;
}
}
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++) {