From: v1ne Date: Tue, 23 Feb 2021 21:36:33 +0000 (+0100) Subject: ols: Don't store temporary data in device context X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=cfe55d09538457ae4d620a0b8c1c81ea979e4954 ols: Don't store temporary data in device context --- diff --git a/src/hardware/openbench-logic-sniffer/protocol.c b/src/hardware/openbench-logic-sniffer/protocol.c index dbf29143..bf065c76 100644 --- a/src/hardware/openbench-logic-sniffer/protocol.c +++ b/src/hardware/openbench-logic-sniffer/protocol.c @@ -476,7 +476,7 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data) * the number of channels. */ j = 0; - memset(devc->tmp_sample, 0, 4); + uint8_t tmp_sample[4] = { 0, 0, 0, 0 }; for (i = 0; i < 4; i++) { if (((devc->capture_flags >> 2) & (1 << i)) == 0) { @@ -485,17 +485,17 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data) * enabled, copy from received * sample. */ - devc->tmp_sample[i] = + tmp_sample[i] = devc->sample[j++]; } else if (devc->capture_flags & CAPTURE_FLAG_DEMUX && (i > 2)) { /* group 2 & 3 get added to 0 & 1 */ - devc->tmp_sample[i - 2] = + tmp_sample[i - 2] = devc->sample[j++]; } } - memcpy(devc->sample, devc->tmp_sample, 4); + memcpy(devc->sample, tmp_sample, 4); sr_spew("Expanded sample: 0x%.2hhx%.2hhx%.2hhx%.2hhx ", devc->sample[3], devc->sample[2], devc->sample[1], devc->sample[0]); diff --git a/src/hardware/openbench-logic-sniffer/protocol.h b/src/hardware/openbench-logic-sniffer/protocol.h index 612b069f..01a38213 100644 --- a/src/hardware/openbench-logic-sniffer/protocol.h +++ b/src/hardware/openbench-logic-sniffer/protocol.h @@ -123,7 +123,6 @@ struct dev_context { unsigned int rle_count; unsigned char sample[4]; - unsigned char tmp_sample[4]; unsigned char *raw_sample_buf; };