]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix -Waddress warnings in nptl/tst-mutex1.c.
authorJoseph Myers <joseph@codesourcery.com>
Tue, 2 Dec 2014 22:33:57 +0000 (22:33 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Tue, 2 Dec 2014 22:33:57 +0000 (22:33 +0000)
This patch fixes -Waddress warnings in nptl/tst-mutex1.c from
comparing the address of an object with NULL (ATTR may either be NULL,
or the address of an object when included from other tests, and the
warning arises in the latter case).  A macro ATTR_NULL is defined
alongside ATTR and used for the tests.

Tested for x86_64.

* nptl/tst-mutex1.c: Include <stdbool.h>.
[!ATTR] (ATTR_NULL): New macro.
(do_test): Test !ATTR_NULL instead of ATTR != NULL.
* nptl/tst-mutexpi1.c (ATTR_NULL): New macro.
* nptl/tst-mutexpp1.c (ATTR_NULL): New macro.

ChangeLog
nptl/tst-mutex1.c
nptl/tst-mutexpi1.c
nptl/tst-mutexpp1.c

index c6ee845ff683e87990b01198e737fa19b9ebdc9a..51df3b5980e948f7b0ce891fef6da0d91f1804ed 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2014-12-02  Joseph Myers  <joseph@codesourcery.com>
 
+       * nptl/tst-mutex1.c: Include <stdbool.h>.
+       [!ATTR] (ATTR_NULL): New macro.
+       (do_test): Test !ATTR_NULL instead of ATTR != NULL.
+       * nptl/tst-mutexpi1.c (ATTR_NULL): New macro.
+       * nptl/tst-mutexpp1.c (ATTR_NULL): New macro.
+
        * posix/tst-getopt_long1.c (do_test): Cast elements of argv array
        to char *.
 
index 2a181e587eaf1a587ca99b8081a858c676ad5b35..27ce54f33ac1ded48c02dad1755b2be8efa6e41d 100644 (file)
 #include <pthread.h>
 #include <stdio.h>
 #include <errno.h>
+#include <stdbool.h>
 
 
 #ifndef ATTR
 # define ATTR NULL
+# define ATTR_NULL true
 #endif
 
 
@@ -32,7 +34,7 @@ do_test (void)
   pthread_mutex_t m;
 
   int e = pthread_mutex_init (&m, ATTR);
-  if (ATTR != NULL && e == ENOTSUP)
+  if (!ATTR_NULL && e == ENOTSUP)
     {
       puts ("cannot support selected type of mutexes");
       return 0;
@@ -43,7 +45,7 @@ do_test (void)
       return 1;
     }
 
-  if (ATTR != NULL && pthread_mutexattr_destroy (ATTR) != 0)
+  if (!ATTR_NULL && pthread_mutexattr_destroy (ATTR) != 0)
     {
       puts ("mutexattr_destroy failed");
       return 1;
index 623ede9fa5a2f1ca92211fc28a67646115f1f106..d768664d026b047faa8fbb1652cecab30ac328aa 100644 (file)
@@ -24,4 +24,5 @@ prepare (void)
 
 
 #define ATTR &a
+#define ATTR_NULL false
 #include "tst-mutex1.c"
index 9b7d7fe2634a8337fadca4f48b97a4a1b5a09c83..8ec4673f1a8c81fee301185290ed3590348df6db 100644 (file)
@@ -42,4 +42,5 @@ do_test_wrapper (void)
 #define TEST_FUNCTION do_test_wrapper ()
 
 #define ATTR &a
+#define ATTR_NULL false
 #include "tst-mutex1.c"