Fixed bug 1801 - typo in the xcf decoder, condition is always false
authorSam Lantinga <slouken@libsdl.org>
Wed, 17 Apr 2013 01:45:53 -0700
changeset 365ce8091caddf3
parent 364 b93e3b562a4f
child 366 f58b3461c128
Fixed bug 1801 - typo in the xcf decoder, condition is always false

blaffablaffa

I'm compiling sdl_image with clang, and it gives this warning:

IMG_xcf.c:523:28: warning: use of logical '&&' with constant operand [-Wconstant-logical-operand]
l = (Uint8)(0.2990 * ((a && 0x00FF0000) >> 16)

This is of course always false, because (a && 0x00FF0000) is '1', so if shifted gives always 0. There are a couple of other similar issues in the same file.
IMG_xcf.c
     1.1 --- a/IMG_xcf.c	Tue Apr 16 09:33:51 2013 -0700
     1.2 +++ b/IMG_xcf.c	Wed Apr 17 01:45:53 2013 -0700
     1.3 @@ -520,9 +520,9 @@
     1.4  
     1.5  static Uint32 rgb2grey (Uint32 a) {
     1.6    Uint8 l;
     1.7 -  l = (Uint8)(0.2990 * ((a && 0x00FF0000) >> 16)
     1.8 -    + 0.5870 * ((a && 0x0000FF00) >>  8)
     1.9 -    + 0.1140 * ((a && 0x000000FF)));
    1.10 +  l = (Uint8)(0.2990 * ((a & 0x00FF0000) >> 16)
    1.11 +    + 0.5870 * ((a & 0x0000FF00) >>  8)
    1.12 +    + 0.1140 * ((a & 0x000000FF)));
    1.13  
    1.14    return (l << 16) | (l << 8) | l;
    1.15  }