[PATCH v2] render: Silence warnings when building with clang

Jeremy Huddleston jeremyhu at freedesktop.org
Mon Apr 25 11:25:04 PDT 2011


picture.c:351:37: error: implicit conversion from 'unsigned int' to 'CARD16' (aka 'unsigned short') changes value from 4294967295 to 65535
      [-Werror,-Wconstant-conversion]
            pFormats[f].direct.alphaMask = Mask(PICT_FORMAT_A(format));
                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
...
fatal error: too many errors emitted, stopping now [-ferror-limit=]

Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
Suggested-by: Jamey Sharp <jamey at minilop.net>

---
 render/picture.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/render/picture.c b/render/picture.c
index e7e1f2b..f0fc5c8 100644
--- a/render/picture.c
+++ b/render/picture.c
@@ -158,7 +158,9 @@ addFormat (FormatInitRec    formats[256],
     return ++nformat;
 }
 
-#define Mask(n)	((n) == 32 ? 0xffffffff : ((1 << (n))-1))
+/* Returns a CARD16 mask, n wide. */
+/*@ requires 0 <= n <= 16 but does not enforce it */
+#define Mask(n) ((1 << (n)) - 1)
 
 PictFormatPtr
 PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp)
-- 
1.7.4.1




More information about the xorg-devel mailing list