Closed CruzR closed 4 years ago
I'd be willing to prepare a pull-request to fix these issues.
The --Wimplicit-fallthrough
warnings can be silenced by adding a comment like /* Intentionally falls through */
to the case statements. (Of course we should first ensure that the fall-through actually is intentional in all cases.)
The --Wformat-overflow
warnings could probably either be silenced by increasing the buffer sizes to the amount suggested by GCC, or by using one of the safe formatting functions (snprintf
, ...) instead.
Thanks for finding and reporting this 👍 I'll go through these in detail later, here are my thoughts so far:
.travis.yml
The warnings are disabled for now
Some of the buffer overflow warnings are because we are doing sprintf with static sized buffers intended to store paths, then doing operations like appending. The logic is that the buffer should be big enough to store any valid path. To fix this we would need to move to dynamic buffers and use functions like snprintf throughout. Will take a bit of refactoring. Perhaps this is a good chance to look at a C string library?
Going to close this as further fixes will be made for #615
GCC 7 adds a couple of new warnings, two of which apply to C-Dogs SDL source code:
--Wimplicit-fallthrough
: Warn when a switch case falls through.--Wformat-overflow
: Warn about calls to formatted input/output functions such assprintf
andvsprintf
that might overflow the destination buffer.Because C-Dogs SDL is compiled with
-Wall -Werror
, compilation fails when using GCC 7.1.Compiling with errors for these two warnings disabled works and yields the following output (irrelevant warnings removed):