From patchwork Thu Feb 26 21:51:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 444079 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 5F11714011D for ; Fri, 27 Feb 2015 08:51:44 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=sourceware.org header.i=@sourceware.org header.b=tcmutJ+F; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=oKNlnCvAH8P7GHUIRaQvI/U9O/2+9 YsYFYkTk57FbiB5iH7mNlQZWrKbxGYkGGYsWl7EzoVQ+ElmV+BluL6CQpJ7b2iU8 1qo9ObDcY1YAi6SOgXdnn8HR2VlphHToaXyk7IGdtq0UJHM9cJncpnfCtetInN67 T8R198d7aQtSFw= 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:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=ZhX3tLbl1TpooXDxNFQ+MgNoUD4=; b=tcm utJ+FMPxRRs+WcAJQXpmbcGeHTvwuQVU1LrvOw4VvZ5kqH4Mv3OQSY1JKMGI5qte NI0oGtF5ky4Uh1rsC8xD0BGd1IQ1noYT9S/mnA7y1hsd4nVM9X+GehnUrRUGoI8r gI2IJdWl/rhOomDOYvxt9pkO/0R+BfSyay8hTldc= Received: (qmail 54074 invoked by alias); 26 Feb 2015 21:51:37 -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 54065 invoked by uid 89); 26 Feb 2015 21:51:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL, BAYES_50, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Date: Thu, 26 Feb 2015 21:51:29 +0000 From: Joseph Myers To: Subject: Avoid uninitialized warnings in Bessel functions [committed] Message-ID: User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 math/Makefile currently has: # The fdlibm code generates a lot of these warnings but is otherwise clean. override CFLAGS += -Wno-uninitialized This is of course undesirable; warnings should be disabled as narrowly as possible. To remove this override, we need to fix files that generate such warnings, or put warning-disabling pragmas in them. This patch does so for Bessel function implementations, one of the cases that have the warnings if the override is removed. The warnings arise because functions set pointer variables p and q only for certain values of the function argument, then use them unconditionally. As the static functions in question only get called for arguments that satisfy the last condition in the if/else chain, the natural fix is to change the last "else if" to just "else", which this patch does. (The ldbl-128 / ldbl-128ibm implementation of these functions is substantially different and looks like it already does use "else" in the last case in the nearest corresponding code.) Tested for x86_64 and x86. Committed. 2015-02-26 Joseph Myers * sysdeps/ieee754/dbl-64/e_j0.c (pzero): Change last case for setting p and q from "else if" to "else". (qzero): Likewise. * sysdeps/ieee754/dbl-64/e_j1.c (pone): Likewise. (qone): Likewise. * sysdeps/ieee754/flt-32/e_j0f.c (pzerof): Likewise. (qzerof): Likewise. * sysdeps/ieee754/flt-32/e_j1f.c (ponef): Likewise. (qonef): Likewise. * sysdeps/ieee754/ldbl-96/e_j0l.c (pzero): Likewise. (qzero): Likewise. * sysdeps/ieee754/ldbl-96/e_j1l.c (pone): Likewise. (qone): Likewise. diff --git a/sysdeps/ieee754/dbl-64/e_j0.c b/sysdeps/ieee754/dbl-64/e_j0.c index d165e80..9f25aa8 100644 --- a/sysdeps/ieee754/dbl-64/e_j0.c +++ b/sysdeps/ieee754/dbl-64/e_j0.c @@ -305,6 +305,7 @@ pzero (double x) int32_t ix; GET_HIGH_WORD (ix, x); ix &= 0x7fffffff; + /* ix >= 0x40000000 for all calls to this function. */ if (ix >= 0x41b00000) { return one; @@ -321,7 +322,7 @@ pzero (double x) { p = pR3; q = pS3; } - else if (ix >= 0x40000000) + else { p = pR2; q = pS2; } @@ -423,6 +424,7 @@ qzero (double x) int32_t ix; GET_HIGH_WORD (ix, x); ix &= 0x7fffffff; + /* ix >= 0x40000000 for all calls to this function. */ if (ix >= 0x41b00000) { return -.125 / x; @@ -439,7 +441,7 @@ qzero (double x) { p = qR3; q = qS3; } - else if (ix >= 0x40000000) + else { p = qR2; q = qS2; } diff --git a/sysdeps/ieee754/dbl-64/e_j1.c b/sysdeps/ieee754/dbl-64/e_j1.c index b7b8a9a..d61cff4 100644 --- a/sysdeps/ieee754/dbl-64/e_j1.c +++ b/sysdeps/ieee754/dbl-64/e_j1.c @@ -305,6 +305,7 @@ pone (double x) int32_t ix; GET_HIGH_WORD (ix, x); ix &= 0x7fffffff; + /* ix >= 0x40000000 for all calls to this function. */ if (ix >= 0x41b00000) { return one; @@ -321,7 +322,7 @@ pone (double x) { p = pr3; q = ps3; } - else if (ix >= 0x40000000) + else { p = pr2; q = ps2; } @@ -424,6 +425,7 @@ qone (double x) int32_t ix; GET_HIGH_WORD (ix, x); ix &= 0x7fffffff; + /* ix >= 0x40000000 for all calls to this function. */ if (ix >= 0x41b00000) { return .375 / x; @@ -440,7 +442,7 @@ qone (double x) { p = qr3; q = qs3; } - else if (ix >= 0x40000000) + else { p = qr2; q = qs2; } diff --git a/sysdeps/ieee754/flt-32/e_j0f.c b/sysdeps/ieee754/flt-32/e_j0f.c index c4cabd5..bd0b80f 100644 --- a/sysdeps/ieee754/flt-32/e_j0f.c +++ b/sysdeps/ieee754/flt-32/e_j0f.c @@ -228,10 +228,11 @@ pzerof(float x) int32_t ix; GET_FLOAT_WORD(ix,x); ix &= 0x7fffffff; + /* ix >= 0x40000000 for all calls to this function. */ if(ix>=0x41000000) {p = pR8; q= pS8;} else if(ix>=0x40f71c58){p = pR5; q= pS5;} else if(ix>=0x4036db68){p = pR3; q= pS3;} - else if(ix>=0x40000000){p = pR2; q= pS2;} + else {p = pR2; q= pS2;} z = one/(x*x); r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4])))); @@ -324,10 +325,11 @@ qzerof(float x) int32_t ix; GET_FLOAT_WORD(ix,x); ix &= 0x7fffffff; + /* ix >= 0x40000000 for all calls to this function. */ if(ix>=0x41000000) {p = qR8; q= qS8;} else if(ix>=0x40f71c58){p = qR5; q= qS5;} else if(ix>=0x4036db68){p = qR3; q= qS3;} - else if(ix>=0x40000000){p = qR2; q= qS2;} + else {p = qR2; q= qS2;} z = one/(x*x); r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5]))))); diff --git a/sysdeps/ieee754/flt-32/e_j1f.c b/sysdeps/ieee754/flt-32/e_j1f.c index 920e4b8..a67da32 100644 --- a/sysdeps/ieee754/flt-32/e_j1f.c +++ b/sysdeps/ieee754/flt-32/e_j1f.c @@ -230,10 +230,11 @@ ponef(float x) int32_t ix; GET_FLOAT_WORD(ix,x); ix &= 0x7fffffff; + /* ix >= 0x40000000 for all calls to this function. */ if(ix>=0x41000000) {p = pr8; q= ps8;} else if(ix>=0x40f71c58){p = pr5; q= ps5;} else if(ix>=0x4036db68){p = pr3; q= ps3;} - else if(ix>=0x40000000){p = pr2; q= ps2;} + else {p = pr2; q= ps2;} z = one/(x*x); r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4])))); @@ -327,10 +328,11 @@ qonef(float x) int32_t ix; GET_FLOAT_WORD(ix,x); ix &= 0x7fffffff; + /* ix >= 0x40000000 for all calls to this function. */ if(ix>=0x40200000) {p = qr8; q= qs8;} else if(ix>=0x40f71c58){p = qr5; q= qs5;} else if(ix>=0x4036db68){p = qr3; q= qs3;} - else if(ix>=0x40000000){p = qr2; q= qs2;} + else {p = qr2; q= qs2;} z = one/(x*x); r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5]))))); diff --git a/sysdeps/ieee754/ldbl-96/e_j0l.c b/sysdeps/ieee754/ldbl-96/e_j0l.c index 56f48f1..a536054 100644 --- a/sysdeps/ieee754/ldbl-96/e_j0l.c +++ b/sysdeps/ieee754/ldbl-96/e_j0l.c @@ -356,6 +356,7 @@ pzero (long double x) GET_LDOUBLE_WORDS (se, i0, i1, x); ix = se & 0x7fff; + /* ix >= 0x4000 for all calls to this function. */ if (ix >= 0x4002) { p = pR8; @@ -374,7 +375,7 @@ pzero (long double x) p = pR3; q = pS3; } - else if (ix >= 0x4000) /* x better be >= 2 */ + else /* x >= 2 */ { p = pR2; q = pS2; @@ -493,6 +494,7 @@ qzero (long double x) GET_LDOUBLE_WORDS (se, i0, i1, x); ix = se & 0x7fff; + /* ix >= 0x4000 for all calls to this function. */ if (ix >= 0x4002) /* x >= 8 */ { p = qR8; @@ -511,7 +513,7 @@ qzero (long double x) p = qR3; q = qS3; } - else if (ix >= 0x4000) /* x better be >= 2 */ + else /* x >= 2 */ { p = qR2; q = qS2; diff --git a/sysdeps/ieee754/ldbl-96/e_j1l.c b/sysdeps/ieee754/ldbl-96/e_j1l.c index 88fcf13..1adc8f6 100644 --- a/sysdeps/ieee754/ldbl-96/e_j1l.c +++ b/sysdeps/ieee754/ldbl-96/e_j1l.c @@ -359,6 +359,7 @@ pone (long double x) GET_LDOUBLE_WORDS (se, i0, i1, x); ix = se & 0x7fff; + /* ix >= 0x4000 for all calls to this function. */ if (ix >= 0x4002) /* x >= 8 */ { p = pr8; @@ -377,7 +378,7 @@ pone (long double x) p = pr3; q = ps3; } - else if (ix >= 0x4000) /* x better be >= 2 */ + else /* x >= 2 */ { p = pr2; q = ps2; @@ -505,6 +506,7 @@ qone (long double x) GET_LDOUBLE_WORDS (se, i0, i1, x); ix = se & 0x7fff; + /* ix >= 0x4000 for all calls to this function. */ if (ix >= 0x4002) /* x >= 8 */ { p = qr8; @@ -523,7 +525,7 @@ qone (long double x) p = qr3; q = qs3; } - else if (ix >= 0x4000) /* x better be >= 2 */ + else /* x >= 2 */ { p = qr2; q = qs2;