From 41b8fca1a16479ebe2761fa63f0dcb86f0bb4c8f Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Sat, 24 Jun 2017 17:23:56 +0200 Subject: [PATCH] input/raw_analog: Fix gcc 7 compiler warnings. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ../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); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- src/input/raw_analog.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); }