]> sourceware.org Git - newlib-cygwin.git/commitdiff
newlib: fix various gcc warnings
authorCorinna Vinschen <corinna@vinschen.de>
Wed, 8 Aug 2018 08:41:58 +0000 (10:41 +0200)
committerCorinna Vinschen <corinna@vinschen.de>
Wed, 8 Aug 2018 08:50:19 +0000 (10:50 +0200)
* unused variables
* potentially used uninitialized
* suggested bracketing
* misleading indentation

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
newlib/libc/stdio/vfscanf.c
newlib/libc/stdlib/ldtoa.c
newlib/libc/stdlib/strtodg.c
newlib/libc/stdlib/strtoimax.c
newlib/libc/stdlib/strtoumax.c
newlib/libc/time/strftime.c
newlib/libm/common/math_config.h
newlib/libm/common/sqrtl.c
newlib/libm/math/ef_jn.c
newlib/libm/math/k_rem_pio2.c
newlib/libm/math/kf_rem_pio2.c

index b972355596fa92b89dafaed802a1de223e54d96a..080dcf400b1c2ce89feff905befb8c6f15bfbdb6 100644 (file)
@@ -421,7 +421,7 @@ __SVFSCANF_R (struct _reent *rptr,
   int nbytes = 1;               /* number of bytes read from fmt string */
   wchar_t wc;                   /* wchar to use to read format string */
   wchar_t *wcp;                 /* handy wide character pointer */
-  size_t mbslen;                /* length of converted multibyte sequence */
+  size_t mbslen = 0;            /* length of converted multibyte sequence */
 #ifdef _MB_CAPABLE
   mbstate_t state;              /* value to keep track of multibyte state */
 #endif
index 10a7537cc25ad8cfd92a21edc5284f9c40547499..751386233f8e7646f07b9426d248d1aa65887a41 100644 (file)
@@ -412,8 +412,10 @@ static void eaddm (short unsigned int *x, short unsigned int *y);
 static void esubm (short unsigned int *x, short unsigned int *y);
 static void emdnorm (short unsigned int *s, int lost, int subflg,
                     long int exp, int rcntrl, LDPARMS * ldp);
+#if 0 /* Broken, unusable implementation of strtold */
 static int asctoeg (char *ss, short unsigned int *y, int oprec,
                    LDPARMS * ldp);
+#endif
 static void enan (short unsigned int *nan, int size);
 #if LDBL_MANT_DIG == 24
 static void toe24 (short unsigned int *x, short unsigned int *y);
@@ -1834,6 +1836,7 @@ e113toe (short unsigned int *pe, short unsigned int *y, LDPARMS * ldp)
 
 /* move out internal format to ieee long double */
 static void
+__attribute__ ((__unused__))
 toe113 (short unsigned int *a, short unsigned int *b)
 {
   register unsigned short *p, *q;
@@ -1970,6 +1973,7 @@ e64toe (short unsigned int *pe, short unsigned int *y, LDPARMS * ldp)
 
 /* move out internal format to ieee long double */
 static void
+__attribute__ ((__unused__))
 toe64 (short unsigned int *a, short unsigned int *b)
 {
   register unsigned short *p, *q;
@@ -2150,6 +2154,7 @@ etoe53 (x, e)
 }
 
 static void
+__attribute__ ((__unused__))
 toe53 (x, y)
      unsigned short *x, *y;
 {
@@ -2159,6 +2164,7 @@ toe53 (x, y)
 #else
 
 static void
+__attribute__ ((__unused__))
 toe53 (short unsigned int *x, short unsigned int *y)
 {
   unsigned short i;
@@ -2327,6 +2333,7 @@ e24toe (short unsigned int *pe, short unsigned int *y, LDPARMS * ldp)
 }
 
 static void
+__attribute__ ((__unused__))
 toe24 (short unsigned int *x, short unsigned int *y)
 {
   unsigned short i;
index d8546c336941e6c3370d6445fb26fc3cd9871ad9..4ac1f8eb218120342418862b535491fbcc58fb04 100644 (file)
@@ -688,13 +688,13 @@ _strtodg_l (struct _reent *p, const char *s00, char **se, FPI *fpi, Long *exp,
                        dval(rv) *= tens[i];
                if (e1 &= ~15) {
                        e1 >>= 4;
-                       while(e1 >= (1 << n_bigtens-1)) {
+                       while(e1 >= (1 << (n_bigtens-1))) {
                                e2 += ((word0(rv) & Exp_mask)
                                        >> Exp_shift1) - Bias;
                                word0(rv) &= ~Exp_mask;
                                word0(rv) |= Bias << Exp_shift1;
                                dval(rv) *= bigtens[n_bigtens-1];
-                               e1 -= 1 << n_bigtens-1;
+                               e1 -= 1 << (n_bigtens-1);
                                }
                        e2 += ((word0(rv) & Exp_mask) >> Exp_shift1) - Bias;
                        word0(rv) &= ~Exp_mask;
@@ -710,13 +710,13 @@ _strtodg_l (struct _reent *p, const char *s00, char **se, FPI *fpi, Long *exp,
                        dval(rv) /= tens[i];
                if (e1 &= ~15) {
                        e1 >>= 4;
-                       while(e1 >= (1 << n_bigtens-1)) {
+                       while(e1 >= (1 << (n_bigtens-1))) {
                                e2 += ((word0(rv) & Exp_mask)
                                        >> Exp_shift1) - Bias;
                                word0(rv) &= ~Exp_mask;
                                word0(rv) |= Bias << Exp_shift1;
                                dval(rv) *= tinytens[n_bigtens-1];
-                               e1 -= 1 << n_bigtens-1;
+                               e1 -= 1 << (n_bigtens-1);
                                }
                        e2 += ((word0(rv) & Exp_mask) >> Exp_shift1) - Bias;
                        word0(rv) &= ~Exp_mask;
@@ -912,7 +912,7 @@ _strtodg_l (struct _reent *p, const char *s00, char **se, FPI *fpi, Long *exp,
                                }
                        else
                                irv = STRTOG_Normal | STRTOG_Inexhi;
-                       if (bbbits < nbits && !denorm || !(rvb->_x[0] & 1))
+                       if ((bbbits < nbits && !denorm) || !(rvb->_x[0] & 1))
                                break;
                        if (dsign) {
                                rvb = increment(p, rvb);
index b0efa3e516bbe6d13a0c238cc42ed34c282ebf6f..6901612c3092a8f0f4be2c4b3377dad18786d8f4 100644 (file)
@@ -60,11 +60,11 @@ static intmax_t
 _strtoimax_l(struct _reent *rptr, const char * __restrict nptr,
             char ** __restrict endptr, int base, locale_t loc)
 {
-       const char *s = (const unsigned char *)nptr;
-       uintmax_t acc;
+       const char *s = nptr;
+       uintmax_t acc = 0;
        char c;
        uintmax_t cutoff;
-       int neg = 0, any, cutlim;
+       int neg = 0, any = 0, cutlim;
 
        /*
         * Skip white space and pick up leading +/- sign if any.
@@ -135,7 +135,6 @@ _strtoimax_l(struct _reent *rptr, const char * __restrict nptr,
                acc = neg ? INTMAX_MIN : INTMAX_MAX;
                rptr->_errno = ERANGE;
        } else if (!any) {
-noconv:
                rptr->_errno = EINVAL;
        } else if (neg)
                acc = -acc;
index aa4a0ac4291773646a5153e481ada3fa2cebe8eb..cf1a427feffa5ec7f55a12f209a4348d1e285181 100644 (file)
@@ -60,7 +60,7 @@ static uintmax_t
 _strtoumax_l(struct _reent *rptr, const char * __restrict nptr,
             char ** __restrict endptr, int base, locale_t loc)
 {
-       const char *s = (const unsigned char *)nptr;
+       const char *s = nptr;
        uintmax_t acc;
        char c;
        uintmax_t cutoff;
index 0cb31238a8811ed527e47b0b3bc73bf3d3f0faf3..429ae99ac4ba4e6fdd028de12590813f7d36570a 100644 (file)
@@ -339,9 +339,6 @@ locale, hard-coding the "C" locale settings.
 #  error "YEAR_BASE < 0"
 #endif
 
-static const int dname_len[7] =
-{6, 6, 7, 9, 8, 6, 8};
-
 /* Using the tm_year, tm_wday, and tm_yday components of TIM_P, return
    -1, 0, or 1 as the adjustment to add to the year for the ISO week
    numbering used in "%g%G%V", avoiding overflow.  */
index d5896bbdd166d0158c66afc55afa04ba500343ce..cca682ed76dd3774c659b92c8cd060d74680ff66 100644 (file)
@@ -205,6 +205,7 @@ opt_barrier_double (double x)
   volatile double y = x;
   return y;
 }
+#pragma GCC diagnostic ignored "-Wunused-variable"
 static inline void
 force_eval_float (float x)
 {
@@ -215,6 +216,7 @@ force_eval_double (double x)
 {
   volatile double y = x;
 }
+#pragma GCC diagnostic pop
 #endif
 
 /* Evaluate an expression as the specified type, normally a type
index 8cd717e194ce8e311c090620132ada37eb40b0ca..9976f35e73e5bde9798d279ddd69622783aa3527 100644 (file)
@@ -123,7 +123,7 @@ long double
 sqrtl (long double x)
 {
   union ieee_ext_u ux = { .extu_ld = x, };
-  int k, r;
+  int k;
   long double lo, xn;
 
   /* If x = NaN, then sqrt(x) = NaN.  */
index bedfb3ed514f3dfa18e6cc8dffab79657c0b4b88..e872c09c7b312e6b0b41753d1b16db70b76d082b 100644 (file)
@@ -20,7 +20,6 @@ static const float
 #else
 static float
 #endif
-invsqrtpi=  5.6418961287e-01, /* 0x3f106ebb */
 two   =  2.0000000000e+00, /* 0x40000000 */
 one   =  1.0000000000e+00; /* 0x3F800000 */
 
index 8569256686c848cdd5f63eb19e6f63ab73861e70..46201874c00adcc438221289c905db5d19eb7536 100644 (file)
@@ -187,7 +187,8 @@ twon24  =  5.96046447753906250000e-08; /* 0x3E700000, 0x00000000 */
 
     /* compute q[0],q[1],...q[jk] */
        for (i=0;i<=jk;i++) {
-           for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw;
+           for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j];
+           q[i] = fw;
        }
 
        jz = jk;
index 261c48129651743ca5b823f7f58deb7922d733f9..1573ca9f629dac4c68e22de930b2d712b5b8e16a 100644 (file)
@@ -77,7 +77,8 @@ twon8  =  3.9062500000e-03; /* 0x3b800000 */
 
     /* compute q[0],q[1],...q[jk] */
        for (i=0;i<=jk;i++) {
-           for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw;
+           for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j];
+           q[i] = fw;
        }
 
        jz = jk;
This page took 0.051128 seconds and 5 git commands to generate.