]> sigrok.org Git - libsigrok.git/commitdiff
lecroy-xstream: fix several compiler warnings (assignment, memory)
authorGerhard Sittig <redacted>
Fri, 9 Feb 2018 18:12:12 +0000 (19:12 +0100)
committerUwe Hermann <redacted>
Fri, 9 Feb 2018 20:37:39 +0000 (21:37 +0100)
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.

src/hardware/lecroy-xstream/api.c
src/hardware/lecroy-xstream/protocol.c

index 070ac7c13f7a4428afcb4c5199f60891da57302e..8c034944eb3b435301cbe0c7dc7bde3dd11af9d8 100644 (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:
index 591f708012d5555524b72f7cfae943ce7671ce04..0c16129f2b4102808c7edc103040c6243459a2b1 100644 (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);