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);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This commit is contained in:
Uwe Hermann 2017-06-24 17:23:56 +02:00
parent 4a465510fb
commit 41b8fca1a1
1 changed files with 2 additions and 2 deletions

View File

@ -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);
}