[PULL] button mapping fix and unconstify patches

Gaetan Nadon memsize at videotron.ca
Mon Feb 10 17:17:54 PST 2014


On 14-02-10 06:57 PM, Keith Packard wrote:
> Gaetan Nadon <memsize at videotron.ca> writes:
>
> Ok, except for -Wshadow, these are all legitimate warnings (and a few
> actual bugs!) that we should fix. I would love for someone to explain
> why my build doesn't generate the useful warnings and why Gaedon's
> compiler is generating the -Wshadow ones...
>
> Thanks, Gaedon!
>
>>      I have a total of 238 warnings.
>>       199 -Wshadow
> All of these are badly named libc/libm functions:
>
>         y0
>         y1
>         gamma
>         index
>         remainder
>         
> I am not seeing any -Wshadow warnings between functions and local
> variables. This example:
>
>         double z1;
>
>         double y1(double x) { return 0; }
>
>         void foo (void) {
>         	int z1 = 0;
>         	int y1 = 0;
>         }
>
> Generates a single warning for me:
>
>         $ cc -Wshadow -c foo.c
>
>         foo.c: In function ‘foo’:
>         foo.c:6:6: warning: declaration of ‘z1’ shadows a global declaration [-Wshadow]
>           int z1 = 0;
>               ^
>         foo.c:1:8: warning: shadowed declaration is here [-Wshadow]
>          double z1;
>                 ^

    nadon at memsize:~/xorg/src$ cc -Wshadow -c foo.c
    foo.c: In function ‘foo’:
    foo.c:6:6: warning: declaration of ‘z1’ shadows a global declaration
    [-Wshadow]
    foo.c:1:8: warning: shadowed declaration is here [-Wshadow]
    foo.c:7:6: warning: declaration of ‘y1’ shadows a global declaration
    [-Wshadow]
    foo.c:3:8: warning: shadowed declaration is here [-Wshadow]

>
> What version of gcc are you using? And, what compiler flags do you end
> up with?
>
>         $ gcc --version
>         gcc (Debian 4.8.2-14) 4.8.2
>
>         $ make V=1
>         gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I../include -DHAVE_DIX_CONFIG_H -Wall -Wpointer-arith -Wmissing-declarations -Wformat=2 -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wbad-function-cast -Wold-style-definition -Wdeclaration-after-statement -Wunused -Wuninitialized -Wshadow -Wmissing-noreturn -Wmissing-format-attribute -Wredundant-decls -Wlogical-op -Werror=implicit -Werror=nonnull -Werror=init-self -Werror=main -Werror=missing-braces -Werror=sequence-point -Werror=return-type -Werror=trigraphs -Werror=array-bounds -Werror=write-strings -Werror=address -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast -fno-strict-aliasing -fno-strict-aliasing -D_BSD_SOURCE -DHAS_FCHOWN -DHAS_STICKY_DIR_BIT -I/local/xorg/include -I/local/xorg/include/pixman-1 -I/local/xorg/include/X11/dri -I/local/xorg/include/libdrm -I/usr/include/freetype2 -I../include -I../include -I../Xext -I../composite -I../damageext -I../xfixes -I../Xi -I../mi -I../miext/sync -I../miext/shadow -I../miext/damage -I../render -I../randr -I../fb -I../dbe -I../present -fvisibility=hidden -O2 -g -MT mitrap.lo -MD -MP -MF .deps/mitrap.Tpo -c mitrap.c  -fPIC -DPIC -o .libs/mitrap.o

    nadon at memsize:~/xorg/src/xserver/render$ gcc --version
    gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
    Copyright (C) 2011 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There
    is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
    PURPOSE.

    nadon at memsize:~/xorg/src/xserver/render$ rm -f mitrap.lo
    nadon at memsize:~/xorg/src/xserver/render$ make V=1
    /bin/bash ../libtool  --tag=CC   --mode=compile gcc -std=gnu99
    -DHAVE_CONFIG_H -I. -I../include    -DHAVE_DIX_CONFIG_H -Wall
    -Wpointer-arith -Wmissing-declarations -Wformat=2
    -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs
    -Wbad-function-cast -Wold-style-definition
    -Wdeclaration-after-statement -Wunused -Wuninitialized -Wshadow
    -Wmissing-noreturn -Wmissing-format-attribute -Wredundant-decls
    -Wlogical-op -Werror=implicit -Werror=nonnull -Werror=init-self
    -Werror=main -Werror=missing-braces -Werror=sequence-point
    -Werror=return-type -Werror=trigraphs -Werror=array-bounds
    -Werror=write-strings -Werror=address -Werror=int-to-pointer-cast
    -Werror=pointer-to-int-cast -fno-strict-aliasing
    -fno-strict-aliasing -D_BSD_SOURCE -DHAS_FCHOWN -DHAS_STICKY_DIR_BIT
    -I/home/nadon/xorg/inst/include
    -I/home/nadon/xorg/inst/include/pixman-1
    -I/home/nadon/xorg/inst/include/X11/dri
    -I/home/nadon/xorg/inst/include/libdrm -I/usr/include/freetype2  
    -I../include -I../include -I../Xext -I../composite -I../damageext
    -I../xfixes -I../Xi -I../mi -I../miext/sync -I../miext/shadow 
    -I../miext/damage -I../render -I../randr -I../fb -I../dbe
    -I../present -fvisibility=hidden -g -O2 -MT mitrap.lo -MD -MP -MF
    .deps/mitrap.Tpo -c -o mitrap.lo mitrap.c

I checked the list of warnings flags and include directives are the same
as expected.

> We need to get the compiler to stop emiting these warnings as it's just
> not reasonable to require that local variables not have the name 'y1' or
> 'index'. I'm very resistant to asserting that these are bugs in the X
> server code; how can we make your compiler work like mine? Is it just
> that you need a newer version of gcc? Or is it that gcc running in
> 64-bit mode is different?
>
>>        35 -Wunused-result
> 28 from test/signal-logging.c, 5 legit bugs in os, 2 bugs in
> xkmread.c. Why am I not seeing these? I cannot get gcc to emit these warnings...
>
> The signal-logging one is trivial to fix (just assert that fgets returns
> non-NULL). The bugs in os and xkbread should also be fairly easy to fix,
> if I could make gcc tell me about them.
>
>>         2 -Wpointer-arith
> 64-bit compiler bug in the test code.
>
>>         1 -Wformat
> test/hashtabletest.c format bug
>
>>         1 -Wunused-function
> That's bswap_CARD64, the only warning I'm getting at present
>
Fascinating.

http://gcc.gnu.org/gcc-4.8/changes.html:

  * The option |-Wshadow| no longer warns if a declaration shadows a
    function declaration, unless the former declares a function or
    pointer to function, because this is a common and valid case in
    real-world code <https://lkml.org/lkml/2006/11/28/239>.

Hopefully people will report what they have on their platforms.
Meanwhile, I'll see if I can setup vmware images and find which versions
of gcc finds what. A short test case for each missing warning would be
easy to test from a Live CD rather than setting up the whole build
environment for X.





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.x.org/archives/xorg-devel/attachments/20140210/c25800f3/attachment.html>


More information about the xorg-devel mailing list