diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2012-08-08 11:04:18 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2012-08-08 11:04:18 +0000 |
commit | 1f232abc8938cc1fe821a6a8504b3845bad89522 (patch) | |
tree | 17abe0c1228139fdf4e2ffff34e7f86cfc55d982 | |
parent | 34a4d873ad02e1be335d4cd57db3e60196e24137 (diff) | |
download | newlib-1f232abc8938cc1fe821a6a8504b3845bad89522.zip newlib-1f232abc8938cc1fe821a6a8504b3845bad89522.tar.gz newlib-1f232abc8938cc1fe821a6a8504b3845bad89522.tar.bz2 |
Throughout, run newlib with -Wall -Werror option and fix bugs and
compiler warnings found this way.
* libc/stdio/freopen.c (_freopen_r): Fix bug setting _flags.
* libc/include/stdio.h (_rename): Define when building newlib.
* libc/include/sys/signal.h (_kill): Ditto.
* libc/include/sys/stat.h (_mkdir): Ditto.
* libc/include/sys/time.h (_gettimeofday): Ditto.
* libc/include/sys/times.h (_times): Ditto.
* libc/include/sys/wait.h (_wait): Ditto.
* libc/locale/lmessages.c (empty): Don't define for Cygwin.
* libc/locale/lmonetary.c (cnv): Ditto.
* libc/locale/nl_langinfo.c (nl_langinfo): Ditto for variable s.
* libc/posix/collate.c: Throughout cast to avoid compiler warning.
* libc/posix/engine.c (matcher): Initialize dp to avoid compiler
warning.
* libc/posix/glob.c: Disable on Cygwin. Explain why.
* libc/posix/regcomp.c: Fix "uninitialized" compiler warnings.
(dissect): Deliberately silence gcc compiler warning. Add comment to
explain why.
* libc/posix/wordexp.c (wordexp): Remove num_bytes variable since result
is never used.
* libc/posix/popen.c (popen): Ditto for variable last.
* libc/reent/mkdirr.c: Include sys/stat.h.
* libc/reent/renamer.c: Include stdio.h.
* libc/search/hash.c: Throughout use underscored variants of the stat
function family.
(init_hash): Add missing definition for the __USE_INTERNAL_STAT64 case.
* libc/search/hash_bigkey.c (__big_insert): Add parenthesis to avoid
compiler warning.
* libc/search/hash_page.c (overflow_page): Initalize freep to NULL to
avoid compiler warning.
* libc/stdio/asiprintf.c (_asiprintf_r): Cast unsigned char * to char *
to avoid compiler warning.
(asiprintf): Ditto.
* libc/stdio/asprintf.c (_asprintf_r): Ditto.
(asprintf): Ditto.
* libc/stdio/vasiprintf.c (_vasiprintf_r): Ditto.
* libc/stdio/vasprintf.c (_vasprintf_r): Ditto.
* libc/stdio/mktemp.c (_gettemp): Cast to unsigned char in call to
isdigit to avoid compiler warning.
* libc/stdio/vfprintf.c (_VFPRINTF_R): Initialize variables used for
grouping to avoid compiler warning. Only define and set nseps and
nrepeats if they are really used.
* libc/stdio/vfwprintf.c (_VFWPRINTF_R): Ditto. Only define state if
it is really used.
* libc/stdio/vfscanf.c (u_char): Revert to be defined as unsigned char.
(__SVFSCANF_R): Cast fmt in call to __mbtowc.
* libc/stdlib/mbtowc_r.c (JIS_state_table): Disable when building
Cygwin.
(JIS_action_table): Ditto.
* libc/stdlib/wctomb_r.c (__utf8_wctomb): Add parenthesis to avoid
compiler warning.
* libc/string/strcasestr.c: Deliberately silence gcc compiler warning.
Add comment to explain why.
* libc/time/strptime.c (strptime): Cast to unsigned char in calls to
isspace to avoid compiler warning.
* libm/math/e_atan2.c (__ieee754_atan2): Add parenthesis to avoid
compiler warning.
* libm/math/e_exp.c (__ieee754_exp): Initialize k to 0 to avoid
compiler warning. Drop setting it to 0 later.
* libm/math/ef_exp.c (__ieee754_expf): Ditto.
* libm/math/e_pow.c (__ieee754_pow): Add braces to avoid compiler
warning.
* libm/math/ef_pow.c (__ieee754_powf): Ditto.
* libm/math/er_lgamma.c (__ieee754_lgamma_r): Initialize nadj to 0 to
avoid compiler warning.
* libm/math/erf_lgamma.c (__ieee754_lgammaf_r): Ditto.
* libm/math/e_rem_pio2.c (__ieee754_rem_pio2): Ditto for variable z.
* libm/common/sf_round.c (roundf): Remove signbit variable since result
is never used.
43 files changed, 187 insertions, 74 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 9d5d039..4fd84ff 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,78 @@ +2012-08-08 Corinna Vinschen <vinschen@redhat.com> + + Throughout, run newlib with -Wall -Werror option and fix bugs and + compiler warnings found this way. + + * libc/stdio/freopen.c (_freopen_r): Fix bug setting _flags. + + * libc/include/stdio.h (_rename): Define when building newlib. + * libc/include/sys/signal.h (_kill): Ditto. + * libc/include/sys/stat.h (_mkdir): Ditto. + * libc/include/sys/time.h (_gettimeofday): Ditto. + * libc/include/sys/times.h (_times): Ditto. + * libc/include/sys/wait.h (_wait): Ditto. + * libc/locale/lmessages.c (empty): Don't define for Cygwin. + * libc/locale/lmonetary.c (cnv): Ditto. + * libc/locale/nl_langinfo.c (nl_langinfo): Ditto for variable s. + * libc/posix/collate.c: Throughout cast to avoid compiler warning. + * libc/posix/engine.c (matcher): Initialize dp to avoid compiler + warning. + * libc/posix/glob.c: Disable on Cygwin. Explain why. + * libc/posix/regcomp.c: Fix "uninitialized" compiler warnings. + (dissect): Deliberately silence gcc compiler warning. Add comment to + explain why. + * libc/posix/wordexp.c (wordexp): Remove num_bytes variable since result + is never used. + * libc/posix/popen.c (popen): Ditto for variable last. + * libc/reent/mkdirr.c: Include sys/stat.h. + * libc/reent/renamer.c: Include stdio.h. + * libc/search/hash.c: Throughout use underscored variants of the stat + function family. + (init_hash): Add missing definition for the __USE_INTERNAL_STAT64 case. + * libc/search/hash_bigkey.c (__big_insert): Add parenthesis to avoid + compiler warning. + * libc/search/hash_page.c (overflow_page): Initalize freep to NULL to + avoid compiler warning. + * libc/stdio/asiprintf.c (_asiprintf_r): Cast unsigned char * to char * + to avoid compiler warning. + (asiprintf): Ditto. + * libc/stdio/asprintf.c (_asprintf_r): Ditto. + (asprintf): Ditto. + * libc/stdio/vasiprintf.c (_vasiprintf_r): Ditto. + * libc/stdio/vasprintf.c (_vasprintf_r): Ditto. + * libc/stdio/mktemp.c (_gettemp): Cast to unsigned char in call to + isdigit to avoid compiler warning. + * libc/stdio/vfprintf.c (_VFPRINTF_R): Initialize variables used for + grouping to avoid compiler warning. Only define and set nseps and + nrepeats if they are really used. + * libc/stdio/vfwprintf.c (_VFWPRINTF_R): Ditto. Only define state if + it is really used. + * libc/stdio/vfscanf.c (u_char): Revert to be defined as unsigned char. + (__SVFSCANF_R): Cast fmt in call to __mbtowc. + * libc/stdlib/mbtowc_r.c (JIS_state_table): Disable when building + Cygwin. + (JIS_action_table): Ditto. + * libc/stdlib/wctomb_r.c (__utf8_wctomb): Add parenthesis to avoid + compiler warning. + * libc/string/strcasestr.c: Deliberately silence gcc compiler warning. + Add comment to explain why. + * libc/time/strptime.c (strptime): Cast to unsigned char in calls to + isspace to avoid compiler warning. + * libm/math/e_atan2.c (__ieee754_atan2): Add parenthesis to avoid + compiler warning. + * libm/math/e_exp.c (__ieee754_exp): Initialize k to 0 to avoid + compiler warning. Drop setting it to 0 later. + * libm/math/ef_exp.c (__ieee754_expf): Ditto. + * libm/math/e_pow.c (__ieee754_pow): Add braces to avoid compiler + warning. + * libm/math/ef_pow.c (__ieee754_powf): Ditto. + * libm/math/er_lgamma.c (__ieee754_lgamma_r): Initialize nadj to 0 to + avoid compiler warning. + * libm/math/erf_lgamma.c (__ieee754_lgammaf_r): Ditto. + * libm/math/e_rem_pio2.c (__ieee754_rem_pio2): Ditto for variable z. + * libm/common/sf_round.c (roundf): Remove signbit variable since result + is never used. + 2012-08-07 Corinna Vinschen <vinschen@redhat.com> * libc/stdlib/mprec.h (Storeinc): Add parenthesis to avoid compiler diff --git a/newlib/libc/include/stdio.h b/newlib/libc/include/stdio.h index 2912eaf..305e409 100644 --- a/newlib/libc/include/stdio.h +++ b/newlib/libc/include/stdio.h @@ -227,6 +227,9 @@ int _EXFUN(sprintf, (char *, const char *, ...) _ATTRIBUTE ((__format__ (__printf__, 2, 3)))); int _EXFUN(remove, (const char *)); int _EXFUN(rename, (const char *, const char *)); +#ifdef _COMPILING_NEWLIB +int _EXFUN(_rename, (const char *, const char *)); +#endif #endif #if !defined(__STRICT_ANSI__) || defined(__USE_XOPEN2K) #ifdef _COMPILING_NEWLIB diff --git a/newlib/libc/include/sys/signal.h b/newlib/libc/include/sys/signal.h index 881df83..4e3be1c 100644 --- a/newlib/libc/include/sys/signal.h +++ b/newlib/libc/include/sys/signal.h @@ -143,6 +143,9 @@ int _EXFUN(pthread_sigmask, (int how, const sigset_t *set, sigset_t *oset)); #undef sigfillset #undef sigismember +#ifdef _COMPILING_NEWLIB +int _EXFUN(_kill, (pid_t, int)); +#endif int _EXFUN(kill, (pid_t, int)); int _EXFUN(killpg, (pid_t, int)); int _EXFUN(sigaction, (int, const struct sigaction *, struct sigaction *)); diff --git a/newlib/libc/include/sys/stat.h b/newlib/libc/include/sys/stat.h index f00caa6..fa2036d 100644 --- a/newlib/libc/include/sys/stat.h +++ b/newlib/libc/include/sys/stat.h @@ -170,8 +170,10 @@ int _EXFUN(futimens, (int, const struct timespec *)); #ifdef _COMPILING_NEWLIB int _EXFUN(_fstat,( int __fd, struct stat *__sbuf )); int _EXFUN(_stat,( const char *__path, struct stat *__sbuf )); +int _EXFUN(_mkdir,( const char *_path, mode_t __mode )); #ifdef __LARGE64_FILES struct stat64; +int _EXFUN(_stat64,( const char *__path, struct stat64 *__sbuf )); int _EXFUN(_fstat64,( int __fd, struct stat64 *__sbuf )); #endif #endif diff --git a/newlib/libc/include/sys/time.h b/newlib/libc/include/sys/time.h index 3c9bf77..b388b2c 100644 --- a/newlib/libc/include/sys/time.h +++ b/newlib/libc/include/sys/time.h @@ -71,6 +71,10 @@ struct itimerval { } while (0) #endif /* defined (__rtems__) || defined (__CYGWIN__) */ +#ifdef _COMPILING_NEWLIB +int _EXFUN(_gettimeofday, (struct timeval *__p, void *__tz)); +#endif + int _EXFUN(gettimeofday, (struct timeval *__p, void *__tz)); int _EXFUN(settimeofday, (const struct timeval *, const struct timezone *)); int _EXFUN(utimes, (const char *__path, const struct timeval *__tvp)); diff --git a/newlib/libc/include/sys/times.h b/newlib/libc/include/sys/times.h index 9375cb1..927812c 100644 --- a/newlib/libc/include/sys/times.h +++ b/newlib/libc/include/sys/times.h @@ -21,6 +21,9 @@ struct tms { }; clock_t _EXFUN(times,(struct tms *)); +#ifdef _COMPILING_NEWLIB +clock_t _EXFUN(_times,(struct tms *)); +#endif #ifdef __cplusplus } diff --git a/newlib/libc/include/sys/wait.h b/newlib/libc/include/sys/wait.h index 0e4a339..73fe372 100644 --- a/newlib/libc/include/sys/wait.h +++ b/newlib/libc/include/sys/wait.h @@ -29,6 +29,10 @@ extern "C" { pid_t wait (int *); pid_t waitpid (pid_t, int *, int); +#ifdef _COMPILING_NEWLIB +pid_t _wait (int *); +#endif + /* Provide prototypes for most of the _<systemcall> names that are provided in newlib for some compilers. */ pid_t _wait (int *); diff --git a/newlib/libc/locale/lmessages.c b/newlib/libc/locale/lmessages.c index 33a4a5a..9fb1df4 100644 --- a/newlib/libc/locale/lmessages.c +++ b/newlib/libc/locale/lmessages.c @@ -35,7 +35,9 @@ #define LCMESSAGES_SIZE_MIN \ (offsetof(struct lc_messages_T, yesstr) / sizeof(char *)) +#ifndef __CYGWIN__ static char empty[] = ""; +#endif static const struct lc_messages_T _C_messages_locale = { "^[yY]" , /* yesexpr */ diff --git a/newlib/libc/locale/lmonetary.c b/newlib/libc/locale/lmonetary.c index f1101a9..80c2d04 100644 --- a/newlib/libc/locale/lmonetary.c +++ b/newlib/libc/locale/lmonetary.c @@ -79,6 +79,7 @@ static struct lc_monetary_T _monetary_locale; static int _monetary_using_locale; static char *_monetary_locale_buf; +#ifndef __CYGWIN__ static char cnv(const char *str) { int i = strtol(str, NULL, 10); @@ -86,6 +87,7 @@ cnv(const char *str) { i = CHAR_MAX; return (char)i; } +#endif int __monetary_load_locale(const char *name , void *f_wctomb, const char *charset) diff --git a/newlib/libc/locale/nl_langinfo.c b/newlib/libc/locale/nl_langinfo.c index 392a7cb..4b7e983 100644 --- a/newlib/libc/locale/nl_langinfo.c +++ b/newlib/libc/locale/nl_langinfo.c @@ -182,7 +182,10 @@ char * _DEFUN(nl_langinfo, (item), nl_item item) { - char *ret, *s, *cs; + char *ret, *cs; +#ifndef __CYGWIN__ + char *s; +#endif static char *csym = NULL; #ifdef TRANSITION_PERIOD_HACK static char *cset = NULL; diff --git a/newlib/libc/posix/collate.c b/newlib/libc/posix/collate.c index 6ee4550..8bb04ef 100644 --- a/newlib/libc/posix/collate.c +++ b/newlib/libc/posix/collate.c @@ -117,24 +117,26 @@ __collate_substitute(s) const u_char *s; { int dest_len, len, nlen; - int delta = strlen(s); + int delta = strlen((const char *) s); u_char *dest_str = NULL; if(s == NULL || *s == '\0') - return __collate_strdup(""); + return __collate_strdup((u_char *) ""); delta += delta / 8; - dest_str = malloc(dest_len = delta); + dest_str = (u_char *) malloc(dest_len = delta); if(dest_str == NULL) __collate_err(EX_OSERR, __FUNCTION__); len = 0; while(*s) { - nlen = len + strlen(__collate_substitute_table[*s]); + nlen = len + strlen((const char *) + __collate_substitute_table[*s]); if (dest_len <= nlen) { dest_str = reallocf(dest_str, dest_len = nlen + delta); if(dest_str == NULL) __collate_err(EX_OSERR, __FUNCTION__); } - strcpy(dest_str + len, __collate_substitute_table[*s++]); + strcpy((char *) dest_str + len, + (const char *) __collate_substitute_table[*s++]); len = nlen; } return dest_str; @@ -150,8 +152,9 @@ __collate_lookup(t, len, prim, sec) *len = 1; *prim = *sec = 0; for(p2 = __collate_chain_pri_table; p2->str[0]; p2++) { - if(strncmp(t, p2->str, strlen(p2->str)) == 0) { - *len = strlen(p2->str); + if(strncmp((const char *) t, (const char *) p2->str, + strlen((const char *) p2->str)) == 0) { + *len = strlen((const char *) p2->str); *prim = p2->prim; *sec = p2->sec; return; @@ -165,7 +168,7 @@ u_char * __collate_strdup(s) u_char *s; { - u_char *t = strdup(s); + u_char *t = (u_char *) strdup((const char *) s); if (t == NULL) __collate_err(EX_OSERR, __FUNCTION__); diff --git a/newlib/libc/posix/engine.c b/newlib/libc/posix/engine.c index 8494b90..5956e27 100644 --- a/newlib/libc/posix/engine.c +++ b/newlib/libc/posix/engine.c @@ -145,7 +145,7 @@ int eflags; int i; struct match mv; struct match *m = &mv; - char *dp; + char *dp = NULL; const sopno gf = g->firststate+1; /* +1 for OEND */ const sopno gl = g->laststate; char *start; @@ -181,8 +181,8 @@ int eflags; pp = mustlast; for (dp = start+g->mlen-1; dp < stop;) { /* Fast skip non-matches */ - while (dp < stop && charjump[*dp]) - dp += charjump[*dp]; + while (dp < stop && charjump[(unsigned char) *dp]) + dp += charjump[(unsigned char) *dp]; if (dp >= stop) break; @@ -198,7 +198,7 @@ int eflags; /* Jump to next possible match */ mj = matchjump[pp - mustfirst]; - cj = charjump[*dp]; + cj = charjump[(unsigned char) *dp]; dp += (cj < mj ? mj : cj); pp = mustlast; } @@ -364,6 +364,9 @@ sopno stopst; char *ssp; /* start of string matched by subsubRE */ char *sep; /* end of string matched by subsubRE */ char *oldssp; /* previous ssp */ +/* dp is only used for assertion testing which, for some reason, is not + recognized as usage. */ +#pragma GCC diagnostic ignored "-Wunused-but-set-variable" char *dp; AT("diss", start, stop, startst, stopst); diff --git a/newlib/libc/posix/glob.c b/newlib/libc/posix/glob.c index 4dafe71..977a5a4 100644 --- a/newlib/libc/posix/glob.c +++ b/newlib/libc/posix/glob.c @@ -30,6 +30,10 @@ * SUCH DAMAGE. */ +#ifdef __CYGWIN__ +#define _NO_GLOB /* Cygwin provides its own glob. */ +#endif + #ifndef _NO_GLOB #if defined(LIBC_SCCS) && !defined(lint) diff --git a/newlib/libc/posix/popen.c b/newlib/libc/posix/popen.c index 38978c7..faf72b6 100644 --- a/newlib/libc/posix/popen.c +++ b/newlib/libc/posix/popen.c @@ -113,7 +113,7 @@ _DEFUN(popen, (program, type), const char *program _AND const char *type) { - struct pid *cur, *last; + struct pid *cur; FILE *iop; int pdes[2], pid; @@ -159,8 +159,7 @@ _DEFUN(popen, (program, type), (void)close(pdes[1]); } /* Close all fd's created by prior popen. */ - for (last = NULL, cur = pidlist; cur; - last = cur, cur = cur->next) + for (cur = pidlist; cur; cur = cur->next) (void)close (fileno (cur->fp)); execl(_PATH_BSHELL, "sh", "-c", program, NULL); _exit(127); diff --git a/newlib/libc/posix/regcomp.c b/newlib/libc/posix/regcomp.c index 7f9e188..bd90d2c 100644 --- a/newlib/libc/posix/regcomp.c +++ b/newlib/libc/posix/regcomp.c @@ -103,8 +103,8 @@ static void freeset(struct parse *p, cset *cs); static int freezeset(struct parse *p, cset *cs); static int firstch(struct parse *p, cset *cs); static int nch(struct parse *p, cset *cs); -static void mcadd(struct parse *p, cset *cs, char *cp); #if used +static void mcadd(struct parse *p, cset *cs, char *cp); static void mcsub(cset *cs, char *cp); static int mcin(cset *cs, char *cp); static char *mcfind(cset *cs, char *cp); @@ -308,8 +308,8 @@ struct parse *p; int stop; /* character this ERE should end at */ { char c; - sopno prevback; - sopno prevfwd; + sopno prevback = 0; + sopno prevfwd = 0; sopno conc; int first = 1; /* is this the first alternative? */ @@ -1333,6 +1333,7 @@ cset *cs; return(n); } +#if used /* - mcadd - add a collating element to a cset == static void mcadd(struct parse *p, cset *cs, \ @@ -1360,7 +1361,6 @@ char *cp; cs->multis[cs->smultis - 1] = '\0'; } -#if used /* - mcsub - subtract a collating element from a cset == static void mcsub(cset *cs, char *cp); @@ -1688,8 +1688,8 @@ struct parse *p; struct re_guts *g; { sop *scan; - sop *start; - sop *newstart; + sop *start = NULL; + sop *newstart = NULL; sopno newlen; sop s; char *cp; @@ -1961,7 +1961,7 @@ struct re_guts *g; * is the first one that would be matched). */ for (mindex = 0; mindex < g->mlen; mindex++) - g->charjump[g->must[mindex]] = g->mlen - mindex - 1; + g->charjump[(unsigned char) g->must[mindex]] = g->mlen - mindex - 1; } /* diff --git a/newlib/libc/posix/wordexp.c b/newlib/libc/posix/wordexp.c index b6c4a6d..bfdb63f 100644 --- a/newlib/libc/posix/wordexp.c +++ b/newlib/libc/posix/wordexp.c @@ -37,7 +37,6 @@ wordexp(const char *words, wordexp_t *pwordexp, int flags) char *iter; pid_t pid; int num_words = 0; - int num_bytes = 0; int fd[2]; int fd_err[2]; int err = 0; @@ -129,8 +128,6 @@ wordexp(const char *words, wordexp_t *pwordexp, int flags) if((iter = strchr(tmp, '\n'))) *iter = '\0'; - num_bytes = atoi(tmp) + pwordexp->we_wordc; - /* Get each expansion from the shell output, and store each in pwordexp's we_wordv vector. */ for(i = 0; i < num_words; i++) diff --git a/newlib/libc/reent/mkdirr.c b/newlib/libc/reent/mkdirr.c index 29d808d..fe36de1 100644 --- a/newlib/libc/reent/mkdirr.c +++ b/newlib/libc/reent/mkdirr.c @@ -44,6 +44,8 @@ DESCRIPTION <<errno>>. */ +#include <sys/stat.h> + int _DEFUN (_mkdir_r, (ptr, path, mode), struct _reent *ptr _AND diff --git a/newlib/libc/reent/renamer.c b/newlib/libc/reent/renamer.c index 4d2d256..d3951a2 100644 --- a/newlib/libc/reent/renamer.c +++ b/newlib/libc/reent/renamer.c @@ -1,6 +1,7 @@ /* Reentrant version of rename system call. */ #include <reent.h> +#include <stdio.h> #include <unistd.h> #include <sys/stat.h> #include <_syslist.h> diff --git a/newlib/libc/search/hash.c b/newlib/libc/search/hash.c index 0301fc0..997acb3 100644 --- a/newlib/libc/search/hash.c +++ b/newlib/libc/search/hash.c @@ -141,9 +141,9 @@ _DEFUN(__hash_open, (file, flags, mode, info, dflags), new_table = 0; if (!file || (flags & O_TRUNC) || #ifdef __USE_INTERNAL_STAT64 - (stat64(file, &statbuf) && (errno == ENOENT))) { + (_stat64(file, &statbuf) && (errno == ENOENT))) { #else - (stat(file, &statbuf) && (errno == ENOENT))) { + (_stat(file, &statbuf) && (errno == ENOENT))) { #endif if (errno == ENOENT) errno = 0; /* Just in case someone looks at errno */ @@ -157,9 +157,9 @@ _DEFUN(__hash_open, (file, flags, mode, info, dflags), a new .db file, then reinitialize the database */ if ((flags & O_CREAT) && #ifdef __USE_INTERNAL_STAT64 - fstat64(hashp->fp, &statbuf) == 0 && statbuf.st_size == 0) + _fstat64(hashp->fp, &statbuf) == 0 && statbuf.st_size == 0) #else - fstat(hashp->fp, &statbuf) == 0 && statbuf.st_size == 0) + _fstat(hashp->fp, &statbuf) == 0 && statbuf.st_size == 0) #endif new_table = 1; @@ -316,7 +316,11 @@ init_hash(hashp, file, info) const char *file; const HASHINFO *info; { +#ifdef __USE_INTERNAL_STAT64 + struct stat64 statbuf; +#else struct stat statbuf; +#endif int nelem; nelem = 1; @@ -335,9 +339,9 @@ init_hash(hashp, file, info) /* Fix bucket size to be optimal for file system */ if (file != NULL) { #ifdef __USE_INTERNAL_STAT64 - if (stat64(file, &statbuf)) + if (_stat64(file, &statbuf)) #else - if (stat(file, &statbuf)) + if (_stat(file, &statbuf)) #endif return (NULL); hashp->BSIZE = statbuf.st_blksize; diff --git a/newlib/libc/search/hash_bigkey.c b/newlib/libc/search/hash_bigkey.c index 449b6be..8ff52b3 100644 --- a/newlib/libc/search/hash_bigkey.c +++ b/newlib/libc/search/hash_bigkey.c @@ -123,7 +123,7 @@ __big_insert(hashp, bufp, key, val) if (!bufp) return (-1); n = p[0]; - if (!key_size) + if (!key_size) { if (FREESPACE(p)) { move_bytes = MIN(FREESPACE(p), val_size); off = OFFSET(p) - move_bytes; @@ -136,6 +136,7 @@ __big_insert(hashp, bufp, key, val) OFFSET(p) = off; } else p[n - 2] = FULL_KEY; + } p = (__uint16_t *)bufp->page; cp = bufp->page; bufp->flags |= BUF_MOD; diff --git a/newlib/libc/search/hash_page.c b/newlib/libc/search/hash_page.c index 68ab9db..7ca304d 100644 --- a/newlib/libc/search/hash_page.c +++ b/newlib/libc/search/hash_page.c @@ -667,7 +667,7 @@ static __uint16_t overflow_page(hashp) HTAB *hashp; { - __uint32_t *freep; + __uint32_t *freep = NULL; int max_free, offset, splitnum; __uint16_t addr; int bit, first_page, free_bit, free_page, i, in_use_bits, j; diff --git a/newlib/libc/stdio/asiprintf.c b/newlib/libc/stdio/asiprintf.c index 97474fd..0c363d5 100644 --- a/newlib/libc/stdio/asiprintf.c +++ b/newlib/libc/stdio/asiprintf.c @@ -45,7 +45,7 @@ _DEFUN(_asiprintf_r, (ptr, strp, fmt), if (ret >= 0) { *f._p = 0; - *strp = f._bf._base; + *strp = (char *) f._bf._base; } return (ret); } @@ -72,7 +72,7 @@ _DEFUN(asiprintf, (strp, fmt), if (ret >= 0) { *f._p = 0; - *strp = f._bf._base; + *strp = (char *) f._bf._base; } return (ret); } diff --git a/newlib/libc/stdio/asprintf.c b/newlib/libc/stdio/asprintf.c index 59a08c8..7b26d9f 100644 --- a/newlib/libc/stdio/asprintf.c +++ b/newlib/libc/stdio/asprintf.c @@ -45,7 +45,7 @@ _DEFUN(_asprintf_r, (ptr, strp, fmt), if (ret >= 0) { *f._p = 0; - *strp = f._bf._base; + *strp = (char *) f._bf._base; } return (ret); } @@ -72,7 +72,7 @@ _DEFUN(asprintf, (strp, fmt), if (ret >= 0) { *f._p = 0; - *strp = f._bf._base; + *strp = (char *) f._bf._base; } return (ret); } diff --git a/newlib/libc/stdio/freopen.c b/newlib/libc/stdio/freopen.c index 6483655..b33eb1e 100644 --- a/newlib/libc/stdio/freopen.c +++ b/newlib/libc/stdio/freopen.c @@ -208,7 +208,7 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp), if (HASLB (fp)) FREELB (ptr, fp); fp->_lb._size = 0; - fp->_flags & ~__SORD; + fp->_flags &= ~__SORD; fp->_flags2 = 0; memset (&fp->_mbstate, 0, sizeof (_mbstate_t)); diff --git a/newlib/libc/stdio/mktemp.c b/newlib/libc/stdio/mktemp.c index 1c5d76d..ecbc7af 100644 --- a/newlib/libc/stdio/mktemp.c +++ b/newlib/libc/stdio/mktemp.c @@ -247,7 +247,7 @@ _DEFUN(_gettemp, (ptr, path, doopen, domkdir, suffixlen, flags), else { /* Safe, since it only encounters 7-bit characters. */ - if (isdigit (*trv)) + if (isdigit ((unsigned char) *trv)) *trv = 'a'; else ++ * trv; diff --git a/newlib/libc/stdio/vasiprintf.c b/newlib/libc/stdio/vasiprintf.c index 15310cc..f96de0d 100644 --- a/newlib/libc/stdio/vasiprintf.c +++ b/newlib/libc/stdio/vasiprintf.c @@ -59,7 +59,7 @@ _DEFUN(_vasiprintf_r, (ptr, strp, fmt, ap), if (ret >= 0) { *f._p = 0; - *strp = f._bf._base; + *strp = (char *) f._bf._base; } return ret; } diff --git a/newlib/libc/stdio/vasprintf.c b/newlib/libc/stdio/vasprintf.c index b89f4db..fbb54cb 100644 --- a/newlib/libc/stdio/vasprintf.c +++ b/newlib/libc/stdio/vasprintf.c @@ -59,7 +59,7 @@ _DEFUN(_vasprintf_r, (ptr, strp, fmt, ap), if (ret >= 0) { *f._p = 0; - *strp = f._bf._base; + *strp = (char *) f._bf._base; } return ret; } diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c index 5598991..4b165e0 100644 --- a/newlib/libc/stdio/vfprintf.c +++ b/newlib/libc/stdio/vfprintf.c @@ -567,9 +567,9 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap), char sign; /* sign prefix (' ', '+', '-', or \0) */ #ifdef _WANT_IO_C99_FORMATS /* locale specific numeric grouping */ - char *thousands_sep; - size_t thsnd_len; - const char *grouping; + char *thousands_sep = NULL; + size_t thsnd_len = 0; + const char *grouping = NULL; #endif #ifdef FLOATING_POINT char *decimal_point = _localeconv_r (data)->decimal_point; @@ -585,7 +585,7 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap), #if defined (FLOATING_POINT) || defined (_WANT_IO_C99_FORMATS) int ndig = 0; /* actual number of digits returned by cvt */ #endif -#ifdef _WANT_IO_C99_FORMATS +#if defined (FLOATING_POINT) && defined (_WANT_IO_C99_FORMATS) int nseps; /* number of group separators with ' */ int nrepeats; /* number of repeats of the last group */ #endif @@ -793,10 +793,10 @@ _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap), sign = '\0'; #ifdef FLOATING_POINT lead = 0; -#endif #ifdef _WANT_IO_C99_FORMATS nseps = nrepeats = 0; #endif +#endif #ifndef _NO_POS_ARGS N = arg_index; is_pos_arg = 0; diff --git a/newlib/libc/stdio/vfscanf.c b/newlib/libc/stdio/vfscanf.c index e05082d..e967719 100644 --- a/newlib/libc/stdio/vfscanf.c +++ b/newlib/libc/stdio/vfscanf.c @@ -243,10 +243,7 @@ static void * get_arg (int, va_list *, int *, void **); #define CT_INT 3 /* integer, i.e., strtol or strtoul */ #define CT_FLOAT 4 /* floating, i.e., strtod */ -#if 0 #define u_char unsigned char -#endif -#define u_char char #define u_long unsigned long #ifndef _NO_LONGLONG @@ -513,8 +510,8 @@ _DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap), #ifndef _MB_CAPABLE wc = *fmt; #else - nbytes = __mbtowc (rptr, &wc, fmt, MB_CUR_MAX, __locale_charset (), - &state); + nbytes = __mbtowc (rptr, &wc, (char *) fmt, MB_CUR_MAX, + __locale_charset (), &state); if (nbytes < 0) { wc = 0xFFFD; /* Unicode replacement character */ nbytes = 1; diff --git a/newlib/libc/stdio/vfwprintf.c b/newlib/libc/stdio/vfwprintf.c index 029f1d0..7d38ecf 100644 --- a/newlib/libc/stdio/vfwprintf.c +++ b/newlib/libc/stdio/vfwprintf.c @@ -396,10 +396,11 @@ _DEFUN(_VFWPRINTF_R, (data, fp, fmt0, ap), wchar_t sign; /* sign prefix (' ', '+', '-', or \0) */ #ifdef _WANT_IO_C99_FORMATS /* locale specific numeric grouping */ - wchar_t thousands_sep; - const char *grouping; + wchar_t thousands_sep = L'\0'; + const char *grouping = NULL; #endif -#ifdef _MB_CAPABLE +#if defined (FLOATING_POINT) && defined (_MB_CAPABLE) \ + && !defined (__HAVE_LOCALE_INFO_EXTENDED__) mbstate_t state; /* mbtowc calls from library must not change state */ #endif #ifdef FLOATING_POINT @@ -415,7 +416,7 @@ _DEFUN(_VFWPRINTF_R, (data, fp, fmt0, ap), #if defined (FLOATING_POINT) || defined (_WANT_IO_C99_FORMATS) int ndig = 0; /* actual number of digits returned by cvt */ #endif -#ifdef _WANT_IO_C99_FORMATS +#if defined (FLOATING_POINT) && defined (_WANT_IO_C99_FORMATS) int nseps; /* number of group separators with ' */ int nrepeats; /* number of repeats of the last group */ #endif @@ -619,10 +620,10 @@ _DEFUN(_VFWPRINTF_R, (data, fp, fmt0, ap), sign = L'\0'; #ifdef FLOATING_POINT lead = 0; -#endif #ifdef _WANT_IO_C99_FORMATS nseps = nrepeats = 0; #endif +#endif #ifndef _NO_POS_ARGS N = arg_index; is_pos_arg = 0; diff --git a/newlib/libc/stdlib/mbtowc_r.c b/newlib/libc/stdlib/mbtowc_r.c index 7c6be69..d84fef5 100644 --- a/newlib/libc/stdlib/mbtowc_r.c +++ b/newlib/libc/stdlib/mbtowc_r.c @@ -78,6 +78,7 @@ typedef enum { COPY_A, COPY_J1, COPY_J2, MAKE_A, NOOP, EMPTY, ERROR } JIS_ACTION * is 2 (switch to JIS) + 2 (JIS characters) + 2 (switch back to ASCII) = 6. *************************************************************************************/ +#ifndef __CYGWIN__ static JIS_STATE JIS_state_table[JIS_S_NUM][JIS_C_NUM] = { /* ESCAPE DOLLAR BRACKET AT B J NUL JIS_CHAR OTHER */ /* ASCII */ { A_ESC, ASCII, ASCII, ASCII, ASCII, ASCII, ASCII, ASCII, ASCII }, @@ -99,6 +100,7 @@ static JIS_ACTION JIS_action_table[JIS_S_NUM][JIS_C_NUM] = { /* J_ESC */ { ERROR, ERROR, NOOP, ERROR, ERROR, ERROR, ERROR, ERROR, ERROR }, /* J_ESC_BR */{ ERROR, ERROR, ERROR, ERROR, MAKE_A, MAKE_A, ERROR, ERROR, ERROR }, }; +#endif /* !__CYGWIN__ */ /* we override the mbstate_t __count field for more complex encodings and use it store a state value */ #define __state __count diff --git a/newlib/libc/stdlib/wctomb_r.c b/newlib/libc/stdlib/wctomb_r.c index 98a0b74..13e1e4c 100644 --- a/newlib/libc/stdlib/wctomb_r.c +++ b/newlib/libc/stdlib/wctomb_r.c @@ -81,7 +81,7 @@ _DEFUN (__utf8_wctomb, (r, s, wchar, charset, state), to return extra 3 bytes. */ wchar_t tmp; tmp = (state->__value.__wchb[0] << 16 | state->__value.__wchb[1] << 8) - - 0x10000 >> 10 | 0xd80d; + - (0x10000 >> 10 | 0xd80d); *s++ = 0xe0 | ((tmp & 0xf000) >> 12); *s++ = 0x80 | ((tmp & 0xfc0) >> 6); *s++ = 0x80 | (tmp & 0x3f); diff --git a/newlib/libc/string/strcasestr.c b/newlib/libc/string/strcasestr.c index 0122d7a..8ff91fd 100644 --- a/newlib/libc/string/strcasestr.c +++ b/newlib/libc/string/strcasestr.c @@ -84,6 +84,8 @@ QUICKREF (!memchr ((h) + (h_l), '\0', (j) + (n_l) - (h_l)) \ && ((h_l) = (j) + (n_l))) # define CANON_ELEMENT(c) tolower (c) +/* strncasecmp uses signed char, CMP_FUNC is expected to use unsigned char. */ +#pragma GCC diagnostic ignored "-Wpointer-sign" # define CMP_FUNC strncasecmp # include "str-two-way.h" #endif diff --git a/newlib/libc/time/strptime.c b/newlib/libc/time/strptime.c index 0fc5f4e..601f93e 100644 --- a/newlib/libc/time/strptime.c +++ b/newlib/libc/time/strptime.c @@ -165,8 +165,8 @@ _DEFUN (strptime, (buf, format, timeptr), char *s; int ret; - if (isspace (c)) { - while (isspace (*buf)) + if (isspace ((unsigned char) c)) { + while (isspace ((unsigned char) *buf)) ++buf; } else if (c == '%' && format[1] != '\0') { c = *++format; diff --git a/newlib/libm/common/sf_round.c b/newlib/libm/common/sf_round.c index 1bf6089..c8f1d77 100644 --- a/newlib/libm/common/sf_round.c +++ b/newlib/libm/common/sf_round.c @@ -18,16 +18,12 @@ float x; #endif { - int signbit; __uint32_t w; /* Most significant word, least significant word. */ int exponent_less_127; GET_FLOAT_WORD(w, x); - /* Extract sign bit. */ - signbit = w & 0x80000000; - /* Extract exponent field. */ exponent_less_127 = (int)((w & 0x7f800000) >> 23) - 127; diff --git a/newlib/libm/math/e_atan2.c b/newlib/libm/math/e_atan2.c index 268be64..8e9650f 100644 --- a/newlib/libm/math/e_atan2.c +++ b/newlib/libm/math/e_atan2.c @@ -73,7 +73,7 @@ pi_lo = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */ if(((ix|((lx|-lx)>>31))>0x7ff00000)|| ((iy|((ly|-ly)>>31))>0x7ff00000)) /* x or y is NaN */ return x+y; - if((hx-0x3ff00000|lx)==0) return atan(y); /* x=1.0 */ + if(((hx-0x3ff00000)|lx)==0) return atan(y); /* x=1.0 */ m = ((hy>>31)&1)|((hx>>30)&2); /* 2*sign(x)+sign(y) */ /* when y = 0 */ diff --git a/newlib/libm/math/e_exp.c b/newlib/libm/math/e_exp.c index ce093c6..e7455ee 100644 --- a/newlib/libm/math/e_exp.c +++ b/newlib/libm/math/e_exp.c @@ -109,7 +109,7 @@ P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */ #endif { double y,hi,lo,c,t; - __int32_t k,xsb; + __int32_t k = 0,xsb; __uint32_t hx; GET_HIGH_WORD(hx,x); @@ -144,7 +144,6 @@ P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */ else if(hx < 0x3e300000) { /* when |x|<2**-28 */ if(huge+x>one) return one+x;/* trigger inexact */ } - else k = 0; /* x is now in primary range */ t = x*x; diff --git a/newlib/libm/math/e_pow.c b/newlib/libm/math/e_pow.c index aac0b42..cad6737 100644 --- a/newlib/libm/math/e_pow.c +++ b/newlib/libm/math/e_pow.c @@ -120,9 +120,10 @@ ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/ /* x|y==NaN return NaN unless x==1 then return 1 */ if(ix > 0x7ff00000 || ((ix==0x7ff00000)&&(lx!=0)) || - iy > 0x7ff00000 || ((iy==0x7ff00000)&&(ly!=0))) + iy > 0x7ff00000 || ((iy==0x7ff00000)&&(ly!=0))) { if(((ix-0x3ff00000)|lx)==0) return one; else return nan(""); + } /* determine if y is an odd int when x < 0 * yisint = 0 ... y is not an integer diff --git a/newlib/libm/math/e_rem_pio2.c b/newlib/libm/math/e_rem_pio2.c index 3e5d0f7..ddfecba 100644 --- a/newlib/libm/math/e_rem_pio2.c +++ b/newlib/libm/math/e_rem_pio2.c @@ -89,7 +89,7 @@ pio2_3t = 8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */ double x,y[]; #endif { - double z,w,t,r,fn; + double z = 0.0,w,t,r,fn; double tx[3]; __int32_t i,j,n,ix,hx; int e0,nx; diff --git a/newlib/libm/math/ef_exp.c b/newlib/libm/math/ef_exp.c index 19c570c..6824f99 100644 --- a/newlib/libm/math/ef_exp.c +++ b/newlib/libm/math/ef_exp.c @@ -47,7 +47,7 @@ P5 = 4.1381369442e-08; /* 0x3331bb4c */ #endif { float y,hi,lo,c,t; - __int32_t k,xsb,sx; + __int32_t k = 0,xsb,sx; __uint32_t hx; GET_FLOAT_WORD(sx,x); @@ -79,7 +79,6 @@ P5 = 4.1381369442e-08; /* 0x3331bb4c */ else if(hx < 0x31800000) { /* when |x|<2**-28 */ if(huge+x>one) return one+x;/* trigger inexact */ } - else k = 0; /* x is now in primary range */ t = x*x; diff --git a/newlib/libm/math/ef_pow.c b/newlib/libm/math/ef_pow.c index 6804ce4..b3041db 100644 --- a/newlib/libm/math/ef_pow.c +++ b/newlib/libm/math/ef_pow.c @@ -77,9 +77,10 @@ ivln2_l = 7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/ /* x|y==NaN return NaN unless x==1 then return 1 */ if(FLT_UWORD_IS_NAN(ix) || - FLT_UWORD_IS_NAN(iy)) + FLT_UWORD_IS_NAN(iy)) { if(ix==0x3f800000) return one; else return nanf(""); + } /* determine if y is an odd int when x < 0 * yisint = 0 ... y is not an integer diff --git a/newlib/libm/math/er_lgamma.c b/newlib/libm/math/er_lgamma.c index 7c9a153..386a8a7 100644 --- a/newlib/libm/math/er_lgamma.c +++ b/newlib/libm/math/er_lgamma.c @@ -216,7 +216,7 @@ static double zero= 0.00000000000000000000e+00; double x; int *signgamp; #endif { - double t,y,z,nadj,p,p1,p2,p3,q,r,w; + double t,y,z,nadj = 0.0,p,p1,p2,p3,q,r,w; __int32_t i,hx,lx,ix; EXTRACT_WORDS(hx,lx,x); diff --git a/newlib/libm/math/erf_lgamma.c b/newlib/libm/math/erf_lgamma.c index 90cc542..3c6ba02 100644 --- a/newlib/libm/math/erf_lgamma.c +++ b/newlib/libm/math/erf_lgamma.c @@ -151,7 +151,7 @@ static float zero= 0.0000000000e+00; float x; int *signgamp; #endif { - float t,y,z,nadj,p,p1,p2,p3,q,r,w; + float t,y,z,nadj = 0.0,p,p1,p2,p3,q,r,w; __int32_t i,hx,ix; GET_FLOAT_WORD(hx,x); |