[hatari-devel] Using more GCC warnings?

Eero Tamminen eerot at users.berlios.de
Sat Sep 18 10:05:51 CEST 2010


Hi,

On Saturday 18 September 2010, Thomas Huth wrote:
> > I already fixed couple of things this complains about, but quite a few
> > functions would need after -Wextra to be explicitly declared as not
> > using all of the arguments given to them.
>
> I personally dislike -Wextra because it generates a lot of annoying
> warnings, especially these "unused parameter" warnings. Not using one
> of the parameters is perfectly legal C, and often also necessary, e.g.
> to meet certain function interface requirements, so I really don't see
> the point in polluting the code with those "__unused" keywords. If you
> really want additional warnings, I would prefer if you use the
> corresponding -Wsomething option directly, and omit -Wunused-parameter
> from the list.

There are quite a lot of warning options included into -Wextra:
           -Wclobbered -Wempty-body -Wignored-qualifiers
           -Wmissing-field-initializers -Wmissing-parameter-type (C only)
           -Wold-style-declaration (C only) -Woverride-init -Wsign-compare
           -Wtype-limits -Wuninitialized (only with -O1 and above)
           -Wunused-parameter (only with -Wunused or -Wall)

But it also does extra things in addition to those:
           The option -Wextra also prints warning messages for the following
           cases:
           *   A pointer is compared against integer zero with
                <, <=, >, or >=.
           * Lots of C++ specific checks...

So I think "-Wextra -Wno-unused-parameter" is better.

With that the only warning comes from here:
--------------
In file included from ./hatari/src/xbios.c:19:
./hatari/src/includes/m68000.h: In function ‘M68000_AddCyclesWithPairing’:
./hatari/src/includes/m68000.h:263: warning: suggest braces around empty 
body in an ‘else’ statement
---------------

Maybe that could be fixed?


Btw. there are also these:
$ grep CMAKE_C_FLAGS $(find -name CMakeLists.txt)
gui-sdl/CMakeLists.txt:set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-write-strings")
uae-cpu/CMakeLists.txt:set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused -Wno-sign-compare -Wno-shadow")

Not checking for sign comparison can leave pretty hard to find bugs.

And at least on Unix, const strings go to a read-only memory section so
trying to write into them would cause a segfault, so it would be nice to fix
sdl-gui at some point too (currently it gives a huge amount of warnings
for that) to find out the issues at compile time instead of run-time...


	- Eero



More information about the hatari-devel mailing list