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