From patchwork Thu Dec 11 08:19:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 419976 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id AA5441400D5 for ; Thu, 11 Dec 2014 19:20:21 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:from:subject:date:message-id:mime-version :content-type; q=dns; s=default; b=GEYFb3Y6fe0X6qgjmFe3DFpzJTi1E deraxGhhM1aryypoVH1F74v0x6qt/EifE6miFB68qWoXBiAmoVqmtdoJXaka6wwC ellToynjFcEgWNwon1QYCc2buw45qmyAKMsDon9OywIKe94myOCMdRDe6yrJ0XIJ W+IOCNkEG6GFyM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:from:subject:date:message-id:mime-version :content-type; s=default; bh=MIpiBmEhFane9+nT88i7CvirkgU=; b=k+O 2O7OQpvCFodaUBBr6JgPThaWmEclbUUywTHQJqfZraMj6EqXpB5ynsNNU68fVo0u gNe230HOMnW7C+aqQhjZBwLI3DYMYO6CAmjK5X848Oy1r71lGRH+7V2Z3Yzad4jA JDWXSKgAQS2m9LK0vf50MLPKBzFMXk1j7gp0qfhQ= Received: (qmail 17077 invoked by alias); 11 Dec 2014 08:20:15 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 17061 invoked by uid 89); 11 Dec 2014 08:20:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: plane.gmane.org To: libc-alpha@sourceware.org From: Stefan Liebler Subject: [PATCH] Get rid of warning comparision will always evaluate as true Date: Thu, 11 Dec 2014 09:19:54 +0100 Lines: 71 Message-ID: Mime-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 Hi, i get the following warning/error while running make xcheck: gcc tst-mutexpp6.c -c ... In file included from tst-mutexpp6.c:45:0: tst-mutex6.c: In function ‘do_test’: tst-mutex6.c:38:12: error: the comparison will always evaluate as ‘true’ for the address of ‘a’ will never be NULL [-Werror=address] if (ATTR != NULL && e == ENOTSUP) ^ tst-mutex6.c:49:12: error: the comparison will always evaluate as ‘true’ for the address of ‘a’ will never be NULL [-Werror=address] if (ATTR != NULL && pthread_mutexattr_destroy (ATTR) != 0) ^ cc1: all warnings being treated as errors In tst-mutexpp6.c ATTR is defined to "a", which is static pthread_mutexattr_t and can´t be NULL. Thus ATTR_NULL is introduced like in tst-mutex1.c, which is set to false in tst-mutexpp6.c to avoid the warning and checks ATTR against NULL in the other cases. Ok to commit? Bye Stefan --- 2014-12-11 Stefan Liebler nptl/tst-mutex6.c (ATTR_NULL): New define checks ATTR against NULL. (do_test): Use !ATTR_NULL instead of ATTR != NULL. nptl/tst-mutexpp6.c (ATTR_NULL): New define. diff --git a/nptl/tst-mutex6.c b/nptl/tst-mutex6.c index 292e3bf..9c11a20 100644 --- a/nptl/tst-mutex6.c +++ b/nptl/tst-mutex6.c @@ -21,6 +21,7 @@ #include #include #include +#include #ifndef ATTR @@ -28,6 +29,9 @@ pthread_mutexattr_t *attr; # define ATTR attr #endif +#ifndef ATTR_NULL +# define ATTR_NULL (ATTR == NULL) +#endif static int do_test (void) @@ -35,7 +39,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"); e = pthread_mutex_init (&m, NULL); @@ -46,7 +50,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; diff --git a/nptl/tst-mutexpp6.c b/nptl/tst-mutexpp6.c index 2ddf6b4..87a6ebd 100644 --- a/nptl/tst-mutexpp6.c +++ b/nptl/tst-mutexpp6.c @@ -42,4 +42,5 @@ do_test_wrapper (void) #define TEST_FUNCTION do_test_wrapper () #define ATTR &a +#define ATTR_NULL false #include "tst-mutex6.c"