This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[BZ #12194] Fix byteswap conversion warning
- From: Andreas Jaeger <aj at suse dot de>
- To: libc-alpha at sources dot redhat dot com
- Cc: Andreas Krebbel <Andreas dot Krebbel at de dot ibm dot com>
- Date: Wed, 20 Jun 2012 09:17:57 +0200
- Subject: [BZ #12194] Fix byteswap conversion warning
The bugreport was closed in October 2010 - but only the x86 versions
were fixed but not the others as noticed today.
Here's a fix for the rest. I tested the generic functions on my system.
Ok to commit?
Andreas, you might want to cleanup the s390 functions, I'm not convinced
that the __tmp variable is needed. Could you test also the patch below,
please?
Andreas
2012-06-20 Andreas Jaeger <aj@suse.de>
[BZ #12194]
* sysdeps/s390/bits/byteswap-16.h (__bswap_16): Avoid -Wconversion
warning.
* sysdeps/s390/bits/byteswap.h (__bswap_constant_16): Likewise.
* bits/byteswap-16.h (__bswap_16): Likewise.
* bits/byteswap.h (__bswap_constant_16): Likewise.
diff --git a/bits/byteswap-16.h b/bits/byteswap-16.h
index 078dd0e..6cc1d30 100644
--- a/bits/byteswap-16.h
+++ b/bits/byteswap-16.h
@@ -23,7 +23,8 @@
#ifdef __GNUC__
# define __bswap_16(x) \
(__extension__ \
- ({ unsigned short int __bsx = (x); __bswap_constant_16 (__bsx); }))
+ ({ unsigned short int __bsx = (unsigned short int) (x); \
+ __bswap_constant_16 (__bsx); }))
#else
static __inline unsigned short int
__bswap_16 (unsigned short int __bsx)
diff --git a/bits/byteswap.h b/bits/byteswap.h
index d818293..3ca0ad6 100644
--- a/bits/byteswap.h
+++ b/bits/byteswap.h
@@ -27,7 +27,7 @@
/* Swap bytes in 16 bit value. */
#define __bswap_constant_16(x) \
- ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8))
+ ((unsigned short int)((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8)))
/* Get __bswap_16. */
#include <bits/byteswap-16.h>
diff --git a/sysdeps/s390/bits/byteswap-16.h b/sysdeps/s390/bits/byteswap-16.h
index 8bfec78..126f382 100644
--- a/sysdeps/s390/bits/byteswap-16.h
+++ b/sysdeps/s390/bits/byteswap-16.h
@@ -28,7 +28,7 @@
# if __WORDSIZE == 64
# define __bswap_16(x) \
(__extension__ \
- ({ unsigned short int __v, __x = (x); \
+ ({ unsigned short int __v, __x = (unsigned short int) (x); \
if (__builtin_constant_p (x)) \
__v = __bswap_constant_16 (__x); \
else { \
@@ -41,7 +41,7 @@
# else
# define __bswap_16(x) \
(__extension__ \
- ({ unsigned short int __v, __x = (x); \
+ ({ unsigned short int __v, __x = (unsigned short int) (x); \
if (__builtin_constant_p (x)) \
__v = __bswap_constant_16 (__x); \
else { \
diff --git a/sysdeps/s390/bits/byteswap.h b/sysdeps/s390/bits/byteswap.h
index e91d4cc..3ae6436 100644
--- a/sysdeps/s390/bits/byteswap.h
+++ b/sysdeps/s390/bits/byteswap.h
@@ -1,5 +1,5 @@
/* Macros to swap the order of bytes in integer values. s390 version.
- Copyright (C) 2000-2003, 2008, 2011, 2012 Free Software Foundation, Inc.
+ Copyright (C) 2000-2012 Free Software Foundation, Inc.
Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
This file is part of the GNU C Library.
@@ -27,7 +27,7 @@
#define _BITS_BYTESWAP_H 1
#define __bswap_constant_16(x) \
- ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
+ ((unsigned short int) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)))
/* Get __bswap_16. */
#include <bits/byteswap-16.h>
--
Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 NÃrnberg, Germany
GF: Jeff Hawn,Jennifer Guild,Felix ImendÃrffer,HRB16746 (AG NÃrnberg)
GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126