]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix sysdeps/ieee754/dbl-64/mpa.c for -Wuninitialized.
authorJoseph Myers <joseph@codesourcery.com>
Thu, 21 May 2015 23:05:45 +0000 (23:05 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Thu, 21 May 2015 23:05:45 +0000 (23:05 +0000)
If you remove the "override CFLAGS += -Wno-uninitialized" in
math/Makefile, one of the errors you get is:

../sysdeps/ieee754/dbl-64/mpa.c: In function '__mp_dbl.part.0':
../sysdeps/ieee754/dbl-64/mpa.c:183:5: error: 'c' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   c *= X[0];

The problem is that the p < 5 case initializes c if p is 1, 2, 3 or 4
but not otherwise, and in fact p is positive for all calls to this
function so the uninitialized case can't actually occur.  This patch
replaces the "if (p == 4)" last case with a comment so the compiler
can see that all paths do initialize c.

Tested for x86_64.

* sysdeps/ieee754/dbl-64/mpa.c (norm): Remove if condition on
(p == 4) case.

ChangeLog
sysdeps/ieee754/dbl-64/mpa.c

index d61c22207a9210252fa3d0e2fa784aca8d9bc85d..bca6ba7a3fe293803b5545595d89ab76a0c83e21 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2015-05-21  Joseph Myers  <joseph@codesourcery.com>
 
+       * sysdeps/ieee754/dbl-64/mpa.c (norm): Remove if condition on
+       (p == 4) case.
+
        * conform/linknamespace.pl (@whitelist): Add re_syntax_options.
        * conform/Makefile (test-xfail-UNIX98/regex.h/linknamespace):
        Remove variable.
index 7d6b0c5a23398b41c421cd677c3b41a1d9be416b..7b52da91d523f6ca71049bfcd1bccedad29016d3 100644 (file)
@@ -119,7 +119,8 @@ __cpy (const mp_no *x, mp_no *y, int p)
 
 #ifndef NO___MP_DBL
 /* Convert a multiple precision number *X into a double precision
-   number *Y, normalized case  (|x| >= 2**(-1022))).  */
+   number *Y, normalized case (|x| >= 2**(-1022))).  X has precision
+   P, which is positive.  */
 static void
 norm (const mp_no *x, double *y, int p)
 {
@@ -135,7 +136,7 @@ norm (const mp_no *x, double *y, int p)
        c = X[1] + R * X[2];
       else if (p == 3)
        c = X[1] + R * (X[2] + R * X[3]);
-      else if (p == 4)
+      else /* p == 4.  */
        c = (X[1] + R * X[2]) + R * R * (X[3] + R * X[4]);
     }
   else