tree.h RB_AUGMENT empty body warning

Dmitri Nikulin dnikulin at gmail.com
Wed Feb 18 03:53:19 PST 2009


Hi all,

I've been using tree.h (
http://www.dragonflybsd.org/cvsweb/src/sys/sys/tree.h ) in C projects
for a long time, and it has bothered me to have "suggest braces around
empty body in if-statement" warnings from GCC. Old GCCs didn't even
have a -Wno-empty-body flag, and I think the GCC in DragonFly itself
doesn't have the warning at all.

I took a look in the header itself and it looks like RB_AUGMENT is
defined as a macro expanding to nothing, and this causes the warnings
in any RB_GENERATE expansion. I don't know the history of tree.h so I
don't know why RB_AUGMENT is there at all, but the simplest solution
I've found is to redeclare it thus:

#define RB_AUGMENT(x) ((void)x)

This avoids the warning with no impact on the generated code. Whether
it's accepted by all desired standards and compilers is beyond my
interest.

Is there any reason to have that macro at all? It is defined only if
it's not already defined in a prior header, so maybe it's declared
differently in different parts of the kernel. If it must be kept, is
the re-definition I gave acceptable as a permanent commit? It will
certainly avoid a lot of warnings with GCC 4.2 and 4.3.

Thanks in advance!

-- 
Dmitri Nikulin

Centre for Synchrotron Science
Monash University
Victoria 3800, Australia





More information about the Users mailing list