With the upgrade of the server we now have GCC 8.2.1 (thanks Opie) and some new warnings (thanks Redhat). I'm surprised no one has posted about them yet. Below are a few examples.
Code:
shop.c: In function ‘shop_keeper’:
shop.c:802:48: warning: ‘%s’ directive output may be truncated writing up to 511 bytes into a region of size 503 [-Wformat-truncation=]
snprintf(tempbuf, sizeof(tempbuf), "$n sells %s.", tempstr);
^~ ~~~~~~~
shop.c:802:3: note: ‘snprintf’ output between 11 and 522 bytes into a destination of size 512
snprintf(tempbuf, sizeof(tempbuf), "$n sells %s.", tempstr);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
shop.c:627:47: warning: ‘%s’ directive output may be truncated writing up to 511 bytes into a region of size 504 [-Wformat-truncation=]
snprintf(tempbuf, sizeof(tempbuf), "$n buys %s.", tempstr);
^~ ~~~~~~~
shop.c:627:3: note: ‘snprintf’ output between 10 and 521 bytes into a destination of size 512
snprintf(tempbuf, sizeof(tempbuf), "$n buys %s.", tempstr);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
shop.c:627:47: warning: ‘%s’ directive output may be truncated writing up to 511 bytes into a region of size 504 [-Wformat-truncation=]
snprintf(tempbuf, sizeof(tempbuf), "$n buys %s.", tempstr);
^~ ~~~~~~~
shop.c:627:3: note: ‘snprintf’ output between 10 and 521 bytes into a destination of size 512
snprintf(tempbuf, sizeof(tempbuf), "$n buys %s.", tempstr);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
shop.c:627:47: warning: ‘%s’ directive output may be truncated writing up to 511 bytes into a region of size 504 [-Wformat-truncation=]
snprintf(tempbuf, sizeof(tempbuf), "$n buys %s.", tempstr);
^~ ~~~~~~~
These are warnings, not bugs and is expected behavior. The only result is snprintf truncating the text. Redhat explains their valid reasoning
here.
The solution would be to define a larger temp buf size as required. But I'm not sure it is worth it.
Warnings can be hidden with Makefile change
MYFLAGS = -Wall
to
MYFLAGS = -Wall -Wno-format-truncation
Appreciate everyone's thoughts or if someone has already tackled this.