public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] newlib: fix various gcc warnings
@ 2018-08-08 8:53 Corinna Vinschen
0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2018-08-08 8:53 UTC (permalink / raw)
To: newlib-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=2d87d95f12bbbb8bff611c8a19b943b9ebedb1fd
commit 2d87d95f12bbbb8bff611c8a19b943b9ebedb1fd
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Wed Aug 8 10:41:58 2018 +0200
newlib: fix various gcc warnings
* unused variables
* potentially used uninitialized
* suggested bracketing
* misleading indentation
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
newlib/libc/stdio/vfscanf.c | 2 +-
newlib/libc/stdlib/ldtoa.c | 7 +++++++
newlib/libc/stdlib/strtodg.c | 10 +++++-----
newlib/libc/stdlib/strtoimax.c | 7 +++----
newlib/libc/stdlib/strtoumax.c | 2 +-
newlib/libc/time/strftime.c | 3 ---
newlib/libm/common/math_config.h | 2 ++
newlib/libm/common/sqrtl.c | 2 +-
newlib/libm/math/ef_jn.c | 1 -
newlib/libm/math/k_rem_pio2.c | 3 ++-
newlib/libm/math/kf_rem_pio2.c | 3 ++-
11 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/newlib/libc/stdio/vfscanf.c b/newlib/libc/stdio/vfscanf.c
index b972355..080dcf4 100644
--- a/newlib/libc/stdio/vfscanf.c
+++ b/newlib/libc/stdio/vfscanf.c
@@ -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
diff --git a/newlib/libc/stdlib/ldtoa.c b/newlib/libc/stdlib/ldtoa.c
index 10a7537..7513862 100644
--- a/newlib/libc/stdlib/ldtoa.c
+++ b/newlib/libc/stdlib/ldtoa.c
@@ -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;
diff --git a/newlib/libc/stdlib/strtodg.c b/newlib/libc/stdlib/strtodg.c
index d8546c3..4ac1f8e 100644
--- a/newlib/libc/stdlib/strtodg.c
+++ b/newlib/libc/stdlib/strtodg.c
@@ -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);
diff --git a/newlib/libc/stdlib/strtoimax.c b/newlib/libc/stdlib/strtoimax.c
index b0efa3e..6901612 100644
--- a/newlib/libc/stdlib/strtoimax.c
+++ b/newlib/libc/stdlib/strtoimax.c
@@ -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;
diff --git a/newlib/libc/stdlib/strtoumax.c b/newlib/libc/stdlib/strtoumax.c
index aa4a0ac..cf1a427 100644
--- a/newlib/libc/stdlib/strtoumax.c
+++ b/newlib/libc/stdlib/strtoumax.c
@@ -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;
diff --git a/newlib/libc/time/strftime.c b/newlib/libc/time/strftime.c
index 0cb3123..429ae99 100644
--- a/newlib/libc/time/strftime.c
+++ b/newlib/libc/time/strftime.c
@@ -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. */
diff --git a/newlib/libm/common/math_config.h b/newlib/libm/common/math_config.h
index d5896bb..cca682e 100644
--- a/newlib/libm/common/math_config.h
+++ b/newlib/libm/common/math_config.h
@@ -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
diff --git a/newlib/libm/common/sqrtl.c b/newlib/libm/common/sqrtl.c
index 8cd717e..9976f35 100644
--- a/newlib/libm/common/sqrtl.c
+++ b/newlib/libm/common/sqrtl.c
@@ -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. */
diff --git a/newlib/libm/math/ef_jn.c b/newlib/libm/math/ef_jn.c
index bedfb3e..e872c09 100644
--- a/newlib/libm/math/ef_jn.c
+++ b/newlib/libm/math/ef_jn.c
@@ -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 */
diff --git a/newlib/libm/math/k_rem_pio2.c b/newlib/libm/math/k_rem_pio2.c
index 8569256..4620187 100644
--- a/newlib/libm/math/k_rem_pio2.c
+++ b/newlib/libm/math/k_rem_pio2.c
@@ -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;
diff --git a/newlib/libm/math/kf_rem_pio2.c b/newlib/libm/math/kf_rem_pio2.c
index 261c481..1573ca9 100644
--- a/newlib/libm/math/kf_rem_pio2.c
+++ b/newlib/libm/math/kf_rem_pio2.c
@@ -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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-08-08 8:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-08 8:53 [newlib-cygwin] newlib: fix various gcc warnings Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).