mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
With gcc 7 we get warnings for code like the following:
44 #define MAX_BUFFER_SIZE_FOR_SUBCHANNEL_ATTRIBUTES 37
406 char buf[MAX_BUFFER_SIZE_FOR_SUBCHANNEL_ATTRIBUTES];
416 device = de_vec[0]->d_name;
417 snprintf(buf, sizeof(buf), "%s", device);
$ grep -r 'd_name\[' /usr/include/
/usr/include/bits/dirent.h: char d_name[256];
The compiler assumes that d_name can be up to 255 characters. Therefore
it produces the following warning:
CC zconf/css/lscss.o
lscss.c: In function 'print_sch_io':
lscss.c:417:31: warning: '%s' directive output may be truncated writing
up to 255 bytes into a region of size 37 [-Wformat-truncation=]
snprintf(buf, sizeof(buf), "%s", device);
^~
In file included from /usr/include/stdio.h:936:0,
from lscss.c:10:
/usr/include/bits/stdio2.h:64:10: note: '__builtin_snprintf' output
between 1 and 256 bytes into a destination of size 37
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix this and use larger buffer sizes to keep gcc quiet.
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>