From: Gerhard Sittig Date: Fri, 9 Feb 2018 18:12:12 +0000 (+0100) Subject: lecroy-xstream: fix several compiler warnings (assignment, memory) X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=f62c2ad65d3c2e20eba512d6460c9c48e17cca08 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. --- diff --git a/src/hardware/lecroy-xstream/api.c b/src/hardware/lecroy-xstream/api.c index 070ac7c1..8c034944 100644 --- a/src/hardware/lecroy-xstream/api.c +++ b/src/hardware/lecroy-xstream/api.c @@ -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: diff --git a/src/hardware/lecroy-xstream/protocol.c b/src/hardware/lecroy-xstream/protocol.c index 591f7080..0c16129f 100644 --- a/src/hardware/lecroy-xstream/protocol.c +++ b/src/hardware/lecroy-xstream/protocol.c @@ -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);