[glib] gtypes: Fix signedness of __builtin_bswap() usage



commit 0e888bdf52fd5f94ca6360886fe3085b646a3ec5
Author: Philip Withnall <withnall endlessm com>
Date:   Sun Oct 1 00:27:31 2017 +0100

    gtypes: Fix signedness of __builtin_bswap() usage
    
    In GUINT64_TO_BE(), for example, when compiling with -Wsign-conversion,
    we get a warning due to an implicit cast from (gint64) to (guint64) when
    passing the argument to __builtin_bswap64().
    
    According to the GCC documentation, __builtin_bswap64() takes an
    unsigned argument:
    
    https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
    
    Cast the input appropriately.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=788384

 glib/gtypes.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/glib/gtypes.h b/glib/gtypes.h
index 0a5a276..047ac62 100644
--- a/glib/gtypes.h
+++ b/glib/gtypes.h
@@ -181,8 +181,8 @@ typedef const gchar *   (*GTranslateFunc)       (const gchar   *str,
 #if defined (__GNUC__) && (__GNUC__ >= 2) && defined (__OPTIMIZE__)
 
 #  if __GNUC__ >= 4 && defined (__GNUC_MINOR__) && __GNUC_MINOR__ >= 3
-#    define GUINT32_SWAP_LE_BE(val) ((guint32) __builtin_bswap32 ((gint32) (val)))
-#    define GUINT64_SWAP_LE_BE(val) ((guint64) __builtin_bswap64 ((gint64) (val)))
+#    define GUINT32_SWAP_LE_BE(val) ((guint32) __builtin_bswap32 ((guint32) (val)))
+#    define GUINT64_SWAP_LE_BE(val) ((guint64) __builtin_bswap64 ((guint64) (val)))
 #  endif
 
 #  if defined (__i386__)


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