From: Uwe Hermann Date: Tue, 30 Jul 2019 18:17:32 +0000 (+0200) Subject: hameg-hmo: Fix two compiler warnings (-Warray-bounds). X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=c38d69adf4f0038871a65eac44bb9ffd84a9786f;p=libsigrok.git hameg-hmo: Fix two compiler warnings (-Warray-bounds). src/hardware/hameg-hmo/protocol.c: In function ‘hmo_scope_state_get’: src/hardware/hameg-hmo/protocol.c:1035:31: warning: array subscript 0 is above array bounds of ‘char *[0]’ [-Warray-bounds] g_free(logic_threshold_short[i]); ~~~~~~~~~~~~~~~~~~~~~^~~ src/hardware/hameg-hmo/protocol.c:1035:31: warning: array subscript 0 is above array bounds of ‘char *[0]’ [-Warray-bounds] src/hardware/hameg-hmo/protocol.c:974:24: warning: array subscript 0 is above array bounds of ‘char *[0]’ [-Warray-bounds] logic_threshold_short[i] = g_strdup((*config->logic_threshold)[i]); ~~~~~~~~~~~~~~~~~~~~~^~~ src/hardware/hameg-hmo/protocol.c:974:24: warning: array subscript 0 is above array bounds of ‘char *[0]’ [-Warray-bounds] --- diff --git a/src/hardware/hameg-hmo/protocol.c b/src/hardware/hameg-hmo/protocol.c index b0875eb5..457fb86b 100644 --- a/src/hardware/hameg-hmo/protocol.c +++ b/src/hardware/hameg-hmo/protocol.c @@ -183,6 +183,9 @@ static const char *logic_threshold_rtb200x_rtm300x[] = { "MAN", // overwritten by logic_threshold_custom }; +/* This might need updates whenever logic_threshold* above change. */ +#define MAX_NUM_LOGIC_THRESHOLD_ENTRIES ARRAY_SIZE(logic_threshold) + /* RTC1002, HMO Compact2 and HMO1002/HMO1202 */ static const char *an2_dig8_trigger_sources[] = { "CH1", "CH2", @@ -942,7 +945,7 @@ static int digital_channel_state_get(struct sr_dev_inst *sdi, { unsigned int i, idx; int result = SR_ERR; - static char *logic_threshold_short[] = {}; + char *logic_threshold_short[MAX_NUM_LOGIC_THRESHOLD_ENTRIES]; char command[MAX_COMMAND_SIZE]; struct sr_channel *ch; struct sr_scpi_dev_inst *scpi = sdi->conn;