[PATCH 1/9] include: fix compiler warning about casting int to uint16_t

Peter Hutterer peter.hutterer at who-t.net
Thu Oct 30 16:52:38 PDT 2014


/usr/include/xorg/misc.h:141:30: warning: implicit conversion loses integer
precision: 'int' to 'uint16_t' (aka 'unsigned short') [-Wconversion]
    return ((x & 0xff) << 8) | ((x >> 8) & 0xff);
        ~~~~~~ ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~

Function sig is a uint16_t, so just force the cast.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 include/misc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/misc.h b/include/misc.h
index 9c2f573..f5b85ee 100644
--- a/include/misc.h
+++ b/include/misc.h
@@ -138,7 +138,7 @@ lswapl(uint32_t x)
 static inline uint16_t
 lswaps(uint16_t x)
 {
-    return ((x & 0xff) << 8) | ((x >> 8) & 0xff);
+    return (uint16_t)((x & 0xff) << 8) | ((x >> 8) & 0xff);
 }
 
 #undef min
-- 
2.1.0



More information about the xorg-devel mailing list