c6d234
commit 4e0b901601038c863b97e68b18ae50a82e10a157
c6d234
Author: Joseph Myers <joseph@codesourcery.com>
c6d234
Date:   Tue Dec 2 22:33:57 2014 +0000
c6d234
c6d234
    Fix -Waddress warnings in nptl/tst-mutex1.c.
c6d234
    
c6d234
    This patch fixes -Waddress warnings in nptl/tst-mutex1.c from
c6d234
    comparing the address of an object with NULL (ATTR may either be NULL,
c6d234
    or the address of an object when included from other tests, and the
c6d234
    warning arises in the latter case).  A macro ATTR_NULL is defined
c6d234
    alongside ATTR and used for the tests.
c6d234
    
c6d234
    Tested for x86_64.
c6d234
    
c6d234
            * nptl/tst-mutex1.c: Include <stdbool.h>.
c6d234
            [!ATTR] (ATTR_NULL): New macro.
c6d234
            (do_test): Test !ATTR_NULL instead of ATTR != NULL.
c6d234
            * nptl/tst-mutexpi1.c (ATTR_NULL): New macro.
c6d234
            * nptl/tst-mutexpp1.c (ATTR_NULL): New macro.
c6d234
c6d234
diff --git a/nptl/tst-mutex1.c b/nptl/tst-mutex1.c
c6d234
index 830c9d1f74076c5d..0f2ae0bf67cfa414 100644
c6d234
--- a/nptl/tst-mutex1.c
c6d234
+++ b/nptl/tst-mutex1.c
c6d234
@@ -19,10 +19,12 @@
c6d234
 #include <pthread.h>
c6d234
 #include <stdio.h>
c6d234
 #include <errno.h>
c6d234
+#include <stdbool.h>
c6d234
 
c6d234
 
c6d234
 #ifndef ATTR
c6d234
 # define ATTR NULL
c6d234
+# define ATTR_NULL true
c6d234
 #endif
c6d234
 
c6d234
 
c6d234
@@ -32,7 +34,7 @@ do_test (void)
c6d234
   pthread_mutex_t m;
c6d234
 
c6d234
   int e = pthread_mutex_init (&m, ATTR);
c6d234
-  if (ATTR != NULL && e == ENOTSUP)
c6d234
+  if (!ATTR_NULL && e == ENOTSUP)
c6d234
     {
c6d234
       puts ("cannot support selected type of mutexes");
c6d234
       return 0;
c6d234
@@ -43,7 +45,7 @@ do_test (void)
c6d234
       return 1;
c6d234
     }
c6d234
 
c6d234
-  if (ATTR != NULL && pthread_mutexattr_destroy (ATTR) != 0)
c6d234
+  if (!ATTR_NULL && pthread_mutexattr_destroy (ATTR) != 0)
c6d234
     {
c6d234
       puts ("mutexattr_destroy failed");
c6d234
       return 1;
c6d234
diff --git a/nptl/tst-mutexpi1.c b/nptl/tst-mutexpi1.c
c6d234
index 623ede9fa5a2f1ca..d768664d026b047f 100644
c6d234
--- a/nptl/tst-mutexpi1.c
c6d234
+++ b/nptl/tst-mutexpi1.c
c6d234
@@ -24,4 +24,5 @@ prepare (void)
c6d234
 
c6d234
 
c6d234
 #define ATTR &a
c6d234
+#define ATTR_NULL false
c6d234
 #include "tst-mutex1.c"
c6d234
diff --git a/nptl/tst-mutexpp1.c b/nptl/tst-mutexpp1.c
c6d234
index 9b7d7fe2634a8337..8ec4673f1a8c81fe 100644
c6d234
--- a/nptl/tst-mutexpp1.c
c6d234
+++ b/nptl/tst-mutexpp1.c
c6d234
@@ -42,4 +42,5 @@ do_test_wrapper (void)
c6d234
 #define TEST_FUNCTION do_test_wrapper ()
c6d234
 
c6d234
 #define ATTR &a
c6d234
+#define ATTR_NULL false
c6d234
 #include "tst-mutex1.c"