New GCC 7 Warnings
- Rumble
-
Topic Author
- Offline
- Administrator
-
Less
More
3 years 8 months ago #8471
by Rumble
Rumble
The Builder Academy
tbamud.com 9091
This email address is being protected from spambots. You need JavaScript enabled to view it.
New GCC 7 Warnings was created by Rumble
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.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.
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);
^~ ~~~~~~~
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.
Rumble
The Builder Academy
tbamud.com 9091
This email address is being protected from spambots. You need JavaScript enabled to view it.
Please Log in or Create an account to join the conversation.
- thomas
-
- Offline
- Administrator
-
Less
More
- Posts: 818
- Thank you received: 159
3 years 8 months ago #8472
by thomas
Replied by thomas on topic New GCC 7 Warnings
I think the correct fix for those is to make the tempstr 15 chars shorter.
I'll try running a build and see how much trouble they are.
I'll try running a build and see how much trouble they are.
Please Log in or Create an account to join the conversation.
- thomas
-
- Offline
- Administrator
-
Less
More
- Posts: 818
- Thank you received: 159
3 years 8 months ago #8473
by thomas
Replied by thomas on topic New GCC 7 Warnings
Some of them were quite bad. I've made a PR with fixes. github.com/tbamud/tbamud/pull/74
Please Log in or Create an account to join the conversation.
- Rumble
-
Topic Author
- Offline
- Administrator
-
3 years 8 months ago #8474
by Rumble
Rumble
The Builder Academy
tbamud.com 9091
This email address is being protected from spambots. You need JavaScript enabled to view it.
Replied by Rumble on topic New GCC 7 Warnings
Thanks Thomas, I plan to put together the 2020 release next week. Appreciate the help. Thanks for Merging Wyld.
Rumble
The Builder Academy
tbamud.com 9091
This email address is being protected from spambots. You need JavaScript enabled to view it.
Please Log in or Create an account to join the conversation.
Time to create page: 0.103 seconds