ATF-devel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: -Werror=unused-but-set-variable

On 08/11/2011 12:08 AM, Julio Merino wrote:
> Unfortunately I don't have access to that gcc version at the moment, but
> see below.  (I'll try to get access to one before the next release to
> ensure that it will build fine "out of the box".)

No problem about it, I guess that, anyway, gcc will detect more and more
of our little bad habits now. We just need to be a bit more careful when
playing with -Werror. :)

> -Wunused is the flag to detect all unused items, and -Wall implies
> -Wunused.  If you take a look at m4/developer-mode.m4, you'll see that
> we are actually passing -Wno-unused-parameter explicitly to disable the
> checking of unused parameters.

Strange because it does not seems to be taken into account.... I have no
explanation for this then.

To workaround this problem I cheated and commented out the setting of
the -Werror in m4/developer-mode.m4 script (but it is a quick and dirty
trick that shouldn't even be mentioned here). And it worked.

> I inherited the -Wno-unused-parameter from the NetBSD standard set of
> strict warning checks and didn't think about it much.
> I think your suggestion means getting rid of this flag so that we
> actually do check for unused parameters; correct? 

In fact, I assumed that the check for unused-variable was induced by the
-Wall and could be deactivated through a call to -Wno-unused. But, I'm
not sure that having explicitly both -Wno-unused and -Wunused in the
same command line will help a lot.

From my experience, the last of the two options will be taken in
consideration and not the other one...

So, using the attribute may be the best way to go for now.

> It seems to be the
> default anyway in gcc 4.6.  I like the idea.
> I'm now working on this locally but the change is quite invasive: I have
> to add many __attribute__((unused)) attributes to the code because some
> unused parameters are legitimate.  That said, there are many unused
> parameters that can be removed :-)
> In the meantime, if you do 'configure --disable-developer' you will
> disable all strict warning checks and you will also disable -Werror,
> which should let you build the code successfully by ignoring any
> warnings that arise.

I might end up doing the --disable-developer once for all. It seems that
many of my current problems are related to this.

>> For now I didn't manage to add the additional flags to the build-system.
>> It seems that using the ATF_BUILD_CFLAGS (and ATF_BUILD_CXXFLAGS) is not
>> enough.
> These variables (ATF_BUILD_*) are used to tune the built-in compiler
> settings that atf will later expose to tests that use the atf_build_*
> functions (see atf-c/build.h).  They do not configure how atf itself is
> built.

Okay, my fault. I should have digged a bit more the variables.

> To tune the flags passed to the compilation of ATF, use the standard
> CFLAGS and CXXFLAGS variables.
> The INSTALL document should be describing all this.  If it feels
> confusing or incomplete, let me know.

Okay, in fact I started by reading the INSTALL and setting the CFLAGS
and CXXFLAGS but it did not work (probably because the options are not
the good way to go to solve this problem).

But, the INSTALL file is perfect.

> Lastly, let me know if the above helps and thanks for your report!



Emmanuel Fleury

It is a capital mistake to theorize in advance of the facts.
 -- Sherlock Holmes, The Adventure of the Second Stain (A. Conan Doyle)

Home | Main Index | Thread Index | Old Index