Use of gcc warning options to find code weaknesses

Discussions related to the BloodsPilot clients
Post Reply
Angeba
Posts: 88
Joined: Sun Feb 06, 2011 11:23 pm

Use of gcc warning options to find code weaknesses

Post 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.
rotunda
Site Admin
Posts: 77
Joined: Wed Mar 24, 2010 2:19 pm

Re: Use of gcc warning options to find code weaknesses

Post 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").
Post Reply