From patchwork Tue Oct 7 15:18:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 3124 Received: (qmail 26436 invoked by alias); 7 Oct 2014 15:18:26 -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 26426 invoked by uid 89); 7 Oct 2014 15:18:25 -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] S/390: Get rid of warning: the comparision will always evaluate as false Date: Tue, 07 Oct 2014 17:18:04 +0200 Lines: 140 Message-ID: Mime-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.8.0 Hi, On s390-32|64 i get the following build warning "sysdeps/s390/s390-64/backtrace.c:133:24: warning: the comparison will always evaluate as ‘false’ for the address of ‘_Unwind_Backtrace’ will never be NULL [-Waddress]" for the non SHARED case. In SHARED case, the _Unwind_Backtrace function is loaded via dlsym() and thus needs to be NULL-checked (if (unwind_backtrace == NULL)) in order to fallback to __backchain_backtrace() function. In non SHARED case, the #define unwind_backtrace _Unwind_Backtrace was introduced with "* sysdeps/s390/s390-32/backtrace.c (init): Guard with #ifdef SHARED." (Roland McGrath 2004-06-11 22:12:55) and the NULL-check will never be false for _Unwind_Backtrace() function. Thus this NULL-check is now only evaluated in SHARED-case. The __backchain_backtrace function is only used in the SHARED-case, if the unwind-function is not found. Thus it is now only compiled in the SHARED-case, to avoid the warning: warning: ‘__backchain_backtrace’ defined but not used [-Wunused-function]. On s390-32, this function is declared as static, but not on s390-64. These functions were introduced in the same patch "Update." (Ulrich Drepper 2003-12-06 01:20:16) and the Changelog from Martin Schwidefsky says: * sysdeps/s390/s390-32/backtrace.c (trace_arg): New structure. (unwind_backtrace, unwind_getip): New variables. (init, __backchain_backtrace, backtrace_helper): New functions. (__backtrace): Use unwind info for backtrace instead of backchain walking if the unwind functions can be found. * sysdeps/s390/s390-64/backtrace.c: Likewise. On s390-64 it isn´t exported in the shared library, thus on s390-64 it is now declared as static too! Bye Stefan --- 2014-10-07 Stefan Liebler * sysdeps/s390/s390-32/backtrace.c (__backtrace): Check for unwind_backtrace == NULL only in SHARED case. (__backchain_backtrace): Compile only in SHARED case. * sysdeps/s390/s390-64/backtrace.c (__backtrace): Likewise. (__backchain_backtrace): Declare as static. diff --git a/sysdeps/s390/s390-32/backtrace.c b/sysdeps/s390/s390-32/backtrace.c index 3ade10c..e3122cf 100644 --- a/sysdeps/s390/s390-32/backtrace.c +++ b/sysdeps/s390/s390-32/backtrace.c @@ -77,10 +77,6 @@ init (void) if (unwind_getip == NULL) unwind_backtrace = NULL; } -#else -# define unwind_backtrace _Unwind_Backtrace -# define unwind_getip _Unwind_GetIP -#endif static int __backchain_backtrace (void **array, int size) @@ -107,6 +103,10 @@ __backchain_backtrace (void **array, int size) return cnt; } +#else +# define unwind_backtrace _Unwind_Backtrace +# define unwind_getip _Unwind_GetIP +#endif static _Unwind_Reason_Code backtrace_helper (struct _Unwind_Context *ctx, void *a) @@ -130,9 +130,10 @@ __backtrace (void **array, int size) __libc_once_define (static, once); __libc_once (once, init); -#endif + if (unwind_backtrace == NULL) return __backchain_backtrace (array, size); +#endif if (size >= 1) unwind_backtrace (backtrace_helper, &arg); diff --git a/sysdeps/s390/s390-64/backtrace.c b/sysdeps/s390/s390-64/backtrace.c index 39a15e0..74b5581 100644 --- a/sysdeps/s390/s390-64/backtrace.c +++ b/sysdeps/s390/s390-64/backtrace.c @@ -76,12 +76,8 @@ init (void) if (unwind_getip == NULL) unwind_backtrace = NULL; } -#else -# define unwind_backtrace _Unwind_Backtrace -# define unwind_getip _Unwind_GetIP -#endif -int +static int __backchain_backtrace (void **array, int size) { /* We assume that all the code is generated with frame pointers set. */ @@ -106,6 +102,10 @@ __backchain_backtrace (void **array, int size) return cnt; } +#else +# define unwind_backtrace _Unwind_Backtrace +# define unwind_getip _Unwind_GetIP +#endif static _Unwind_Reason_Code backtrace_helper (struct _Unwind_Context *ctx, void *a) @@ -129,9 +129,10 @@ __backtrace (void **array, int size) __libc_once_define (static, once); __libc_once (once, init); -#endif + if (unwind_backtrace == NULL) return __backchain_backtrace (array, size); +#endif if (size >= 1) unwind_backtrace (backtrace_helper, &arg);