newlib: fix various gcc warnings

* unused variables
* potentially used uninitialized
* suggested bracketing
* misleading indentation

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2018-08-08 10:41:58 +02:00
parent 5ace9004d9
commit 2d87d95f12
11 changed files with 24 additions and 18 deletions

View File

@ -421,7 +421,7 @@ __SVFSCANF_R (struct _reent *rptr,
int nbytes = 1; /* number of bytes read from fmt string */ int nbytes = 1; /* number of bytes read from fmt string */
wchar_t wc; /* wchar to use to read format string */ wchar_t wc; /* wchar to use to read format string */
wchar_t *wcp; /* handy wide character pointer */ 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 #ifdef _MB_CAPABLE
mbstate_t state; /* value to keep track of multibyte state */ mbstate_t state; /* value to keep track of multibyte state */
#endif #endif

View 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 esubm (short unsigned int *x, short unsigned int *y);
static void emdnorm (short unsigned int *s, int lost, int subflg, static void emdnorm (short unsigned int *s, int lost, int subflg,
long int exp, int rcntrl, LDPARMS * ldp); 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, static int asctoeg (char *ss, short unsigned int *y, int oprec,
LDPARMS * ldp); LDPARMS * ldp);
#endif
static void enan (short unsigned int *nan, int size); static void enan (short unsigned int *nan, int size);
#if LDBL_MANT_DIG == 24 #if LDBL_MANT_DIG == 24
static void toe24 (short unsigned int *x, short unsigned int *y); 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 */ /* move out internal format to ieee long double */
static void static void
__attribute__ ((__unused__))
toe113 (short unsigned int *a, short unsigned int *b) toe113 (short unsigned int *a, short unsigned int *b)
{ {
register unsigned short *p, *q; 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 */ /* move out internal format to ieee long double */
static void static void
__attribute__ ((__unused__))
toe64 (short unsigned int *a, short unsigned int *b) toe64 (short unsigned int *a, short unsigned int *b)
{ {
register unsigned short *p, *q; register unsigned short *p, *q;
@ -2150,6 +2154,7 @@ etoe53 (x, e)
} }
static void static void
__attribute__ ((__unused__))
toe53 (x, y) toe53 (x, y)
unsigned short *x, *y; unsigned short *x, *y;
{ {
@ -2159,6 +2164,7 @@ toe53 (x, y)
#else #else
static void static void
__attribute__ ((__unused__))
toe53 (short unsigned int *x, short unsigned int *y) toe53 (short unsigned int *x, short unsigned int *y)
{ {
unsigned short i; unsigned short i;
@ -2327,6 +2333,7 @@ e24toe (short unsigned int *pe, short unsigned int *y, LDPARMS * ldp)
} }
static void static void
__attribute__ ((__unused__))
toe24 (short unsigned int *x, short unsigned int *y) toe24 (short unsigned int *x, short unsigned int *y)
{ {
unsigned short i; unsigned short i;

View File

@ -688,13 +688,13 @@ _strtodg_l (struct _reent *p, const char *s00, char **se, FPI *fpi, Long *exp,
dval(rv) *= tens[i]; dval(rv) *= tens[i];
if (e1 &= ~15) { if (e1 &= ~15) {
e1 >>= 4; e1 >>= 4;
while(e1 >= (1 << n_bigtens-1)) { while(e1 >= (1 << (n_bigtens-1))) {
e2 += ((word0(rv) & Exp_mask) e2 += ((word0(rv) & Exp_mask)
>> Exp_shift1) - Bias; >> Exp_shift1) - Bias;
word0(rv) &= ~Exp_mask; word0(rv) &= ~Exp_mask;
word0(rv) |= Bias << Exp_shift1; word0(rv) |= Bias << Exp_shift1;
dval(rv) *= bigtens[n_bigtens-1]; dval(rv) *= bigtens[n_bigtens-1];
e1 -= 1 << n_bigtens-1; e1 -= 1 << (n_bigtens-1);
} }
e2 += ((word0(rv) & Exp_mask) >> Exp_shift1) - Bias; e2 += ((word0(rv) & Exp_mask) >> Exp_shift1) - Bias;
word0(rv) &= ~Exp_mask; 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]; dval(rv) /= tens[i];
if (e1 &= ~15) { if (e1 &= ~15) {
e1 >>= 4; e1 >>= 4;
while(e1 >= (1 << n_bigtens-1)) { while(e1 >= (1 << (n_bigtens-1))) {
e2 += ((word0(rv) & Exp_mask) e2 += ((word0(rv) & Exp_mask)
>> Exp_shift1) - Bias; >> Exp_shift1) - Bias;
word0(rv) &= ~Exp_mask; word0(rv) &= ~Exp_mask;
word0(rv) |= Bias << Exp_shift1; word0(rv) |= Bias << Exp_shift1;
dval(rv) *= tinytens[n_bigtens-1]; dval(rv) *= tinytens[n_bigtens-1];
e1 -= 1 << n_bigtens-1; e1 -= 1 << (n_bigtens-1);
} }
e2 += ((word0(rv) & Exp_mask) >> Exp_shift1) - Bias; e2 += ((word0(rv) & Exp_mask) >> Exp_shift1) - Bias;
word0(rv) &= ~Exp_mask; word0(rv) &= ~Exp_mask;
@ -912,7 +912,7 @@ _strtodg_l (struct _reent *p, const char *s00, char **se, FPI *fpi, Long *exp,
} }
else else
irv = STRTOG_Normal | STRTOG_Inexhi; irv = STRTOG_Normal | STRTOG_Inexhi;
if (bbbits < nbits && !denorm || !(rvb->_x[0] & 1)) if ((bbbits < nbits && !denorm) || !(rvb->_x[0] & 1))
break; break;
if (dsign) { if (dsign) {
rvb = increment(p, rvb); rvb = increment(p, rvb);

View File

@ -60,11 +60,11 @@ static intmax_t
_strtoimax_l(struct _reent *rptr, const char * __restrict nptr, _strtoimax_l(struct _reent *rptr, const char * __restrict nptr,
char ** __restrict endptr, int base, locale_t loc) char ** __restrict endptr, int base, locale_t loc)
{ {
const char *s = (const unsigned char *)nptr; const char *s = nptr;
uintmax_t acc; uintmax_t acc = 0;
char c; char c;
uintmax_t cutoff; uintmax_t cutoff;
int neg = 0, any, cutlim; int neg = 0, any = 0, cutlim;
/* /*
* Skip white space and pick up leading +/- sign if any. * 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; acc = neg ? INTMAX_MIN : INTMAX_MAX;
rptr->_errno = ERANGE; rptr->_errno = ERANGE;
} else if (!any) { } else if (!any) {
noconv:
rptr->_errno = EINVAL; rptr->_errno = EINVAL;
} else if (neg) } else if (neg)
acc = -acc; acc = -acc;

View File

@ -60,7 +60,7 @@ static uintmax_t
_strtoumax_l(struct _reent *rptr, const char * __restrict nptr, _strtoumax_l(struct _reent *rptr, const char * __restrict nptr,
char ** __restrict endptr, int base, locale_t loc) char ** __restrict endptr, int base, locale_t loc)
{ {
const char *s = (const unsigned char *)nptr; const char *s = nptr;
uintmax_t acc; uintmax_t acc;
char c; char c;
uintmax_t cutoff; uintmax_t cutoff;

View File

@ -339,9 +339,6 @@ locale, hard-coding the "C" locale settings.
# error "YEAR_BASE < 0" # error "YEAR_BASE < 0"
#endif #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 /* 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 -1, 0, or 1 as the adjustment to add to the year for the ISO week
numbering used in "%g%G%V", avoiding overflow. */ numbering used in "%g%G%V", avoiding overflow. */

View File

@ -205,6 +205,7 @@ opt_barrier_double (double x)
volatile double y = x; volatile double y = x;
return y; return y;
} }
#pragma GCC diagnostic ignored "-Wunused-variable"
static inline void static inline void
force_eval_float (float x) force_eval_float (float x)
{ {
@ -215,6 +216,7 @@ force_eval_double (double x)
{ {
volatile double y = x; volatile double y = x;
} }
#pragma GCC diagnostic pop
#endif #endif
/* Evaluate an expression as the specified type, normally a type /* Evaluate an expression as the specified type, normally a type

View File

@ -123,7 +123,7 @@ long double
sqrtl (long double x) sqrtl (long double x)
{ {
union ieee_ext_u ux = { .extu_ld = x, }; union ieee_ext_u ux = { .extu_ld = x, };
int k, r; int k;
long double lo, xn; long double lo, xn;
/* If x = NaN, then sqrt(x) = NaN. */ /* If x = NaN, then sqrt(x) = NaN. */

View File

@ -20,7 +20,6 @@ static const float
#else #else
static float static float
#endif #endif
invsqrtpi= 5.6418961287e-01, /* 0x3f106ebb */
two = 2.0000000000e+00, /* 0x40000000 */ two = 2.0000000000e+00, /* 0x40000000 */
one = 1.0000000000e+00; /* 0x3F800000 */ one = 1.0000000000e+00; /* 0x3F800000 */

View File

@ -187,7 +187,8 @@ twon24 = 5.96046447753906250000e-08; /* 0x3E700000, 0x00000000 */
/* compute q[0],q[1],...q[jk] */ /* compute q[0],q[1],...q[jk] */
for (i=0;i<=jk;i++) { 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; jz = jk;

View File

@ -77,7 +77,8 @@ twon8 = 3.9062500000e-03; /* 0x3b800000 */
/* compute q[0],q[1],...q[jk] */ /* compute q[0],q[1],...q[jk] */
for (i=0;i<=jk;i++) { 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; jz = jk;