Coping with -Wunused-but-set-variable, first round

Jeremy Huddleston jeremyhu at apple.com
Fri May 20 10:53:24 PDT 2011


On the whole, this gets my ACK as this will clear up a bit of the clang static analysis noise, but some of the changes feel suspicious to me.  It feels like some of the dead code was there for a reason, and maybe the fix is to *use* the value properly.  In other cases where I'm more familiar with the code, it looks clear to me that values once were needed and changes in "the right way" meant we no longer passed those values along.

Did you do a 'git blame' to figure out when the dead code was added to get some context and make sure that the once-needed values are really no longer required?  Obviously things "work" now, but I'd hate to come back in 2 years to find out that we acted the wrong way on a particular warning.


On May 20, 2011, at 08:34, Cyril Brulebois wrote:

> Hi,
> 
> gcc 4.6 has -Wunused-but-set-variable[1]:
> ,----
> | New -Wunused-but-set-variable and -Wunused-but-set-parameter warnings
> | were added for C, C++, Objective-C and Objective-C++. These warnings
> | diagnose variables respective parameters which are only set in the
> | code and never otherwise used. Usually such variables are useless and
> | often even the value assigned to them is computed needlessly,
> | sometimes expensively. The -Wunused-but-set-variable warning is
> | enabled by default by -Wall flag and -Wunused-but-set-parameter by
> | -Wall -Wextra flags.
> `----
> 
> 1. http://gcc.gnu.org/gcc-4.6/changes.html
> 
> We have a lot of hits, but with the upcoming patchset (30 patches…) we
> go down from 126 to 91; remaining parts include fb*, shrotpack*.h,
> render2swap.c stuff, which I was a bit reluctant to patch without
> thinking of it a bit. So the patchset should only have “easy to
> ACK/NACK” items.
> 
> It's also available in my repository:
>  git://anongit.freedesktop.org/~kibi/xserver unused-but-set-variable
> 
> Mraw,
> KiBi.
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel



More information about the xorg-devel mailing list