Page 1 of 1

Use of gcc warning options to find code weaknesses

Posted: Sun Feb 20, 2011 9:11 pm
by Angeba
Building the bloodspilot clients with gcc's warning options, results in _lots_ of warning messages.
I used "CFLAGS=-Wall -Wconversion -Wshadow -pedantic -Wredundant-decls" .
To read more about gcc's warning options try:
info gcc "Invoking GCC" "Warning Options".

An example of such warnings is:
"pointer_move_next defined twice".
The variable "pointer_move_next" is declared both in global.c and in netclient.c.
As I understand, it can be intentional to declare/define variables/functions multiple times,
but it may also lead to wrong behaviour if that happens accidentally.
The wrong variables may be accessed and thus wrong values may be used.
Probably each warning needs to be investigated individually, to find out if there should be
only one instance or if there need to be multiple objects.

This looks like a lot of work, but it may be very useful.

Re: Use of gcc warning options to find code weaknesses

Posted: Sat May 07, 2011 11:36 pm
by rotunda
I agree we should eliminate most (if not all) warnings. Some can be harmless, but do not have to (e.g. "pointer targets in passing argument N of ‘XXX’ differ in signedness").