This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

S390: Fix build failure in test string/tst-endian.c with gcc 6.


Hi,

Building string/tst-endian.c with gcc 6 produces an build warning/error on s390:
gcc tst-endian.c -c -std=gnu11 -fgnu89-inline  -O2 or -O3 ...
tst-endian.c: In function âdo_testâ:
tst-endian.c:16:30: error: self-comparison always evaluates to false [-Werror=tautological-compare]
    if (htobe16 (be16toh (i)) != i)
                              ^~

tst-endian.c:48:30: error: self-comparison always evaluates to false [-Werror=tautological-compare]
    if (htobe32 (be32toh (i)) != i)
                              ^~

tst-endian.c:78:33: error: self-comparison always evaluates to false [-Werror=tautological-compare]
       if (htobe64 (be64toh (i)) != i)
                                 ^~

See definitions of htobexx, bexxtoh in string/endian.h:
# if __BYTE_ORDER == __LITTLE_ENDIAN
...
# else
#  define htobe16(x) (x)
#  define be16toh(x) (x)
#  define htobe32(x) (x)
#  define be32toh(x) (x)
#  define htobe64(x) (x)
#  define be64toh(x) (x)
# endif

This patch makes these if-statements conditional on __BYTE_ORDER == __LITTLE_ENDIAN.

Ok to commit?

Bye Stefan

ChangeLog:

	* string/tst-endian.c (do_test): Make htobexx( bexxtoh (i)) != i
	if-statements conditional on __BYTE_ORDER == __LITTLE_ENDIAN.
diff --git a/string/tst-endian.c b/string/tst-endian.c
index 8684bb2..d093587 100644
--- a/string/tst-endian.c
+++ b/string/tst-endian.c
@@ -13,12 +13,14 @@ do_test (void)
     {
       if (i < UINT64_C (65536))
 	{
+#if __BYTE_ORDER == __LITTLE_ENDIAN
 	  if (htobe16 (be16toh (i)) != i)
 	    {
 	      printf ("htobe16 (be16toh (%" PRIx64 ")) == %" PRIx16 "\n",
 		      i, (uint16_t) htobe16 (be16toh (i)));
 	      result = 1;
 	    }
+#endif
 	  if (htole16 (le16toh (i)) != i)
 	    {
 	      printf ("htole16 (le16toh (%" PRIx64 ")) == %" PRIx16 "\n",
@@ -45,12 +47,14 @@ do_test (void)
 
       if (i < UINT64_C (4294967296))
 	{
+#if __BYTE_ORDER == __LITTLE_ENDIAN
 	  if (htobe32 (be32toh (i)) != i)
 	    {
 	      printf ("htobe32 (be32toh (%" PRIx64 ")) == %" PRIx32 "\n",
 		      i, (uint32_t) htobe32 (be32toh (i)));
 	      result = 1;
 	    }
+#endif
 	  if (htole32 (le32toh (i)) != i)
 	    {
 	      printf ("htole32 (le32toh (%" PRIx64 ")) == %" PRIx32 "\n",
@@ -75,12 +79,14 @@ do_test (void)
 	    }
 	}
 
+#if __BYTE_ORDER == __LITTLE_ENDIAN
       if (htobe64 (be64toh (i)) != i)
 	{
 	  printf ("htobe64 (be64toh (%" PRIx64 ")) == %" PRIx64 "\n",
 		  i, htobe64 (be64toh (i)));
 	  result = 1;
 	}
+#endif
       if (htole64 (le64toh (i)) != i)
 	{
 	  printf ("htole64 (le64toh (%" PRIx64 ")) == %" PRIx64 "\n",

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]