lecroy-xstream: fix several compiler warnings (assignment, memory)

Remove an assignment that won't take effect. Check pointers' validity
before dereferencing. Fix a memory leak.

This was reported by clang's scan-build.
This commit is contained in:
Gerhard Sittig 2018-02-09 19:12:12 +01:00 committed by Uwe Hermann
parent b65adcedb8
commit f62c2ad65d
2 changed files with 4 additions and 2 deletions

View File

@ -213,8 +213,6 @@ static int config_set(uint32_t key, GVariant *data,
model = devc->model_config;
state = devc->model_state;
ret = SR_ERR_NA;
switch (key) {
case SR_CONF_LIMIT_FRAMES:
devc->frame_limit = g_variant_get_uint64(data);
@ -324,6 +322,8 @@ static int config_list(uint32_t key, GVariant **data,
*data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_analog));
break;
case SR_CONF_COUPLING:
if (!model)
return SR_ERR_ARG;
*data = g_variant_new_strv(*model->coupling_options, model->num_coupling_options);
break;
case SR_CONF_TRIGGER_SOURCE:

View File

@ -665,6 +665,8 @@ SR_PRIV int lecroy_xstream_receive_data(int fd, int revents, void *cb_data)
return SR_ERR;
if (analog.num_samples == 0) {
g_free(analog.data);
/* No data available, we have to acquire data first. */
g_snprintf(command, sizeof(command), "ARM;WAIT;*OPC;C%d:WAVEFORM?", ch->index + 1);
sr_scpi_send(sdi->conn, command);