From: Uwe Hermann Date: Sat, 24 Jun 2017 15:23:56 +0000 (+0200) Subject: input/raw_analog: Fix gcc 7 compiler warnings. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=41b8fca1a16479ebe2761fa63f0dcb86f0bb4c8f;p=libsigrok.git input/raw_analog: Fix gcc 7 compiler warnings. ../src/input/raw_analog.c: In function ‘init’: ../src/input/raw_analog.c:133:31: warning: ‘%d’ directive output may be truncated writing between 1 and 10 bytes into a region of size 6 [-Wformat-truncation=] snprintf(channelname, 8, "CH%d", i + 1); ^~ ../src/input/raw_analog.c:133:28: note: directive argument in the range [1, 2147483647] snprintf(channelname, 8, "CH%d", i + 1); ^~~~~~ ../src/input/raw_analog.c:133:3: note: ‘snprintf’ output between 4 and 13 bytes into a destination of size 8 snprintf(channelname, 8, "CH%d", i + 1); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- diff --git a/src/input/raw_analog.c b/src/input/raw_analog.c index 95b1d669..f6a02635 100644 --- a/src/input/raw_analog.c +++ b/src/input/raw_analog.c @@ -105,7 +105,7 @@ static int init(struct sr_input *in, GHashTable *options) { struct context *inc; int num_channels; - char channelname[8]; + char channelname[16]; const char *format; int fmt_index; @@ -130,7 +130,7 @@ static int init(struct sr_input *in, GHashTable *options) in->priv = inc = g_malloc0(sizeof(struct context)); for (int i = 0; i < num_channels; i++) { - snprintf(channelname, 8, "CH%d", i + 1); + snprintf(channelname, sizeof(channelname) - 1, "CH%d", i + 1); sr_channel_new(in->sdi, i, SR_CHANNEL_ANALOG, TRUE, channelname); }