[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#561249: Spurious warning with -Wconversion (uint16_t/htons) in -O2 mode



The analysis given above is correct.

The following patch fixes the (quite annoying) problem for me:

--- /usr/include/bits/byteswap.h.old    2010-06-26 21:39:16.000000000 +0200
+++ /usr/include/bits/byteswap.h        2010-06-26 21:39:49.000000000 +0200
@@ -29,7 +29,7 @@
 
 /* Swap bytes in 16 bit value.  */
 #define __bswap_constant_16(x) \
-     ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
+     ((unsigned short int)((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)))
 
 #if defined __GNUC__ && __GNUC__ >= 2
 # define __bswap_16(x) \




Reply to: