[patch] Fix compiler warnings throughout
Corinna Vinschen
vinschen@redhat.com
Fri Aug 10 09:38:00 GMT 2012
Hi,
I just applied the below patch. The idea was to be able to compile
newlib with gcc options set to -Wall -Werror to better support porting
to new targets. So the below patch fixes all problems which showed up
when running with these options, like uninitialized variables, suggested
parenthesis and braces, as well as real bug which was only uncovered by
using these options in freopen.c
Please have a look if something is broken for your target now. I don't
think so, but still...
Corinna
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.
Index: libc/include/stdio.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/stdio.h,v
retrieving revision 1.61
diff -u -p -r1.61 stdio.h
--- libc/include/stdio.h 26 Feb 2010 09:41:43 -0000 1.61
+++ libc/include/stdio.h 8 Aug 2012 11:01:25 -0000
@@ -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
Index: libc/include/sys/signal.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/sys/signal.h,v
retrieving revision 1.20
diff -u -p -r1.20 signal.h
--- libc/include/sys/signal.h 19 Apr 2011 08:02:59 -0000 1.20
+++ libc/include/sys/signal.h 8 Aug 2012 11:01:25 -0000
@@ -143,6 +143,9 @@ int _EXFUN(pthread_sigmask, (int how, co
#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 *));
Index: libc/include/sys/stat.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/sys/stat.h,v
retrieving revision 1.23
diff -u -p -r1.23 stat.h
--- libc/include/sys/stat.h 6 Aug 2010 18:26:21 -0000 1.23
+++ libc/include/sys/stat.h 8 Aug 2012 11:01:25 -0000
@@ -170,8 +170,10 @@ int _EXFUN(futimens, (int, const struct
#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
Index: libc/include/sys/time.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/sys/time.h,v
retrieving revision 1.15
diff -u -p -r1.15 time.h
--- libc/include/sys/time.h 6 Jul 2012 10:41:21 -0000 1.15
+++ libc/include/sys/time.h 8 Aug 2012 11:01:25 -0000
@@ -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));
Index: libc/include/sys/times.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/sys/times.h,v
retrieving revision 1.2
diff -u -p -r1.2 times.h
--- libc/include/sys/times.h 4 Dec 2000 18:47:07 -0000 1.2
+++ libc/include/sys/times.h 8 Aug 2012 11:01:25 -0000
@@ -21,6 +21,9 @@ struct tms {
};
clock_t _EXFUN(times,(struct tms *));
+#ifdef _COMPILING_NEWLIB
+clock_t _EXFUN(_times,(struct tms *));
+#endif
#ifdef __cplusplus
}
Index: libc/include/sys/wait.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/sys/wait.h,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 wait.h
--- libc/include/sys/wait.h 17 Feb 2000 19:39:46 -0000 1.1.1.1
+++ libc/include/sys/wait.h 8 Aug 2012 11:01:25 -0000
@@ -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 *);
Index: libc/locale/lmessages.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/locale/lmessages.c,v
retrieving revision 1.5
diff -u -p -r1.5 lmessages.c
--- libc/locale/lmessages.c 19 Jul 2011 19:24:45 -0000 1.5
+++ libc/locale/lmessages.c 8 Aug 2012 11:01:25 -0000
@@ -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 */
Index: libc/locale/lmonetary.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/locale/lmonetary.c,v
retrieving revision 1.4
diff -u -p -r1.4 lmonetary.c
--- libc/locale/lmonetary.c 28 Apr 2010 09:59:37 -0000 1.4
+++ libc/locale/lmonetary.c 8 Aug 2012 11:01:25 -0000
@@ -79,6 +79,7 @@ static struct lc_monetary_T _monetary_lo
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)
Index: libc/locale/nl_langinfo.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/locale/nl_langinfo.c,v
retrieving revision 1.13
diff -u -p -r1.13 nl_langinfo.c
--- libc/locale/nl_langinfo.c 3 May 2010 09:25:32 -0000 1.13
+++ libc/locale/nl_langinfo.c 8 Aug 2012 11:01:25 -0000
@@ -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;
Index: libc/posix/collate.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/posix/collate.c,v
retrieving revision 1.3
diff -u -p -r1.3 collate.c
--- libc/posix/collate.c 25 May 2011 18:41:10 -0000 1.3
+++ libc/posix/collate.c 8 Aug 2012 11:01:26 -0000
@@ -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__);
Index: libc/posix/engine.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/posix/engine.c,v
retrieving revision 1.1
diff -u -p -r1.1 engine.c
--- libc/posix/engine.c 31 Oct 2008 21:03:41 -0000 1.1
+++ libc/posix/engine.c 8 Aug 2012 11:01:26 -0000
@@ -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);
Index: libc/posix/glob.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/posix/glob.c,v
retrieving revision 1.1
diff -u -p -r1.1 glob.c
--- libc/posix/glob.c 31 Oct 2008 21:03:41 -0000 1.1
+++ libc/posix/glob.c 8 Aug 2012 11:01:26 -0000
@@ -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)
Index: libc/posix/popen.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/posix/popen.c,v
retrieving revision 1.9
diff -u -p -r1.9 popen.c
--- libc/posix/popen.c 18 Aug 2009 17:07:55 -0000 1.9
+++ libc/posix/popen.c 8 Aug 2012 11:01:26 -0000
@@ -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);
Index: libc/posix/regcomp.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/posix/regcomp.c,v
retrieving revision 1.1
diff -u -p -r1.1 regcomp.c
--- libc/posix/regcomp.c 31 Oct 2008 21:03:41 -0000 1.1
+++ libc/posix/regcomp.c 8 Aug 2012 11:01:26 -0000
@@ -103,8 +103,8 @@ static void freeset(struct parse *p, cse
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;
}
/*
Index: libc/posix/wordexp.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/posix/wordexp.c,v
retrieving revision 1.1
diff -u -p -r1.1 wordexp.c
--- libc/posix/wordexp.c 31 Oct 2008 21:03:41 -0000 1.1
+++ libc/posix/wordexp.c 8 Aug 2012 11:01:27 -0000
@@ -37,7 +37,6 @@ wordexp(const char *words, wordexp_t *pw
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 *pw
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++)
Index: libc/reent/mkdirr.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/reent/mkdirr.c,v
retrieving revision 1.1
diff -u -p -r1.1 mkdirr.c
--- libc/reent/mkdirr.c 12 Aug 2009 18:22:38 -0000 1.1
+++ libc/reent/mkdirr.c 8 Aug 2012 11:01:27 -0000
@@ -44,6 +44,8 @@ DESCRIPTION
<<errno>>.
*/
+#include <sys/stat.h>
+
int
_DEFUN (_mkdir_r, (ptr, path, mode),
struct _reent *ptr _AND
Index: libc/reent/renamer.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/reent/renamer.c,v
retrieving revision 1.2
diff -u -p -r1.2 renamer.c
--- libc/reent/renamer.c 24 Nov 2008 21:27:33 -0000 1.2
+++ libc/reent/renamer.c 8 Aug 2012 11:01:27 -0000
@@ -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>
Index: libc/search/hash.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/search/hash.c,v
retrieving revision 1.10
diff -u -p -r1.10 hash.c
--- libc/search/hash.c 5 Mar 2010 08:55:15 -0000 1.10
+++ libc/search/hash.c 8 Aug 2012 11:01:27 -0000
@@ -141,9 +141,9 @@ _DEFUN(__hash_open, (file, flags, mode,
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,
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;
Index: libc/search/hash_bigkey.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/search/hash_bigkey.c,v
retrieving revision 1.3
diff -u -p -r1.3 hash_bigkey.c
--- libc/search/hash_bigkey.c 7 Jun 2006 19:22:59 -0000 1.3
+++ libc/search/hash_bigkey.c 8 Aug 2012 11:01:27 -0000
@@ -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;
Index: libc/search/hash_page.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/search/hash_page.c,v
retrieving revision 1.4
diff -u -p -r1.4 hash_page.c
--- libc/search/hash_page.c 19 Sep 2002 21:28:51 -0000 1.4
+++ libc/search/hash_page.c 8 Aug 2012 11:01:27 -0000
@@ -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;
Index: libc/stdio/asiprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/asiprintf.c,v
retrieving revision 1.5
diff -u -p -r1.5 asiprintf.c
--- libc/stdio/asiprintf.c 30 Apr 2008 02:47:14 -0000 1.5
+++ libc/stdio/asiprintf.c 8 Aug 2012 11:01:27 -0000
@@ -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);
}
Index: libc/stdio/asprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/asprintf.c,v
retrieving revision 1.9
diff -u -p -r1.9 asprintf.c
--- libc/stdio/asprintf.c 14 Apr 2008 21:14:55 -0000 1.9
+++ libc/stdio/asprintf.c 8 Aug 2012 11:01:27 -0000
@@ -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);
}
Index: libc/stdio/freopen.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/freopen.c,v
retrieving revision 1.26
diff -u -p -r1.26 freopen.c
--- libc/stdio/freopen.c 30 May 2012 08:58:42 -0000 1.26
+++ libc/stdio/freopen.c 8 Aug 2012 11:01:27 -0000
@@ -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));
Index: libc/stdio/mktemp.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/mktemp.c,v
retrieving revision 1.15
diff -u -p -r1.15 mktemp.c
--- libc/stdio/mktemp.c 19 Jul 2010 18:21:11 -0000 1.15
+++ libc/stdio/mktemp.c 8 Aug 2012 11:01:27 -0000
@@ -247,7 +247,7 @@ _DEFUN(_gettemp, (ptr, path, doopen, dom
else
{
/* Safe, since it only encounters 7-bit characters. */
- if (isdigit (*trv))
+ if (isdigit ((unsigned char) *trv))
*trv = 'a';
else
++ * trv;
Index: libc/stdio/vasiprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/vasiprintf.c,v
retrieving revision 1.5
diff -u -p -r1.5 vasiprintf.c
--- libc/stdio/vasiprintf.c 19 Aug 2011 17:00:32 -0000 1.5
+++ libc/stdio/vasiprintf.c 8 Aug 2012 11:01:27 -0000
@@ -59,7 +59,7 @@ _DEFUN(_vasiprintf_r, (ptr, strp, fmt, a
if (ret >= 0)
{
*f._p = 0;
- *strp = f._bf._base;
+ *strp = (char *) f._bf._base;
}
return ret;
}
Index: libc/stdio/vasprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/vasprintf.c,v
retrieving revision 1.8
diff -u -p -r1.8 vasprintf.c
--- libc/stdio/vasprintf.c 19 Aug 2011 17:00:32 -0000 1.8
+++ libc/stdio/vasprintf.c 8 Aug 2012 11:01:27 -0000
@@ -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;
}
Index: libc/stdio/vfprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/vfprintf.c,v
retrieving revision 1.81
diff -u -p -r1.81 vfprintf.c
--- libc/stdio/vfprintf.c 30 May 2012 08:58:42 -0000 1.81
+++ libc/stdio/vfprintf.c 8 Aug 2012 11:01:28 -0000
@@ -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;
Index: libc/stdio/vfscanf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/vfscanf.c,v
retrieving revision 1.52
diff -u -p -r1.52 vfscanf.c
--- libc/stdio/vfscanf.c 30 May 2012 08:58:42 -0000 1.52
+++ libc/stdio/vfscanf.c 8 Aug 2012 11:01:28 -0000
@@ -243,10 +243,7 @@ static void * get_arg (int, va_list *, i
#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;
Index: libc/stdio/vfwprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/vfwprintf.c,v
retrieving revision 1.8
diff -u -p -r1.8 vfwprintf.c
--- libc/stdio/vfwprintf.c 30 May 2012 08:58:42 -0000 1.8
+++ libc/stdio/vfwprintf.c 8 Aug 2012 11:01:28 -0000
@@ -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;
Index: libc/stdlib/mbtowc_r.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdlib/mbtowc_r.c,v
retrieving revision 1.20
diff -u -p -r1.20 mbtowc_r.c
--- libc/stdlib/mbtowc_r.c 17 Jan 2010 09:39:06 -0000 1.20
+++ libc/stdlib/mbtowc_r.c 8 Aug 2012 11:01:28 -0000
@@ -78,6 +78,7 @@ typedef enum { COPY_A, COPY_J1, COPY_J2,
* 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
/* 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
Index: libc/stdlib/wctomb_r.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdlib/wctomb_r.c,v
retrieving revision 1.18
diff -u -p -r1.18 wctomb_r.c
--- libc/stdlib/wctomb_r.c 17 Jan 2010 09:39:06 -0000 1.18
+++ libc/stdlib/wctomb_r.c 8 Aug 2012 11:01:28 -0000
@@ -81,7 +81,7 @@ _DEFUN (__utf8_wctomb, (r, s, wchar, cha
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);
Index: libc/string/strcasestr.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/string/strcasestr.c,v
retrieving revision 1.4
diff -u -p -r1.4 strcasestr.c
--- libc/string/strcasestr.c 19 Aug 2011 16:58:20 -0000 1.4
+++ libc/string/strcasestr.c 8 Aug 2012 11:01:28 -0000
@@ -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
Index: libc/time/strptime.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/time/strptime.c,v
retrieving revision 1.8
diff -u -p -r1.8 strptime.c
--- libc/time/strptime.c 19 Aug 2011 16:58:20 -0000 1.8
+++ libc/time/strptime.c 8 Aug 2012 11:01:28 -0000
@@ -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;
Index: libm/common/sf_round.c
===================================================================
RCS file: /cvs/src/src/newlib/libm/common/sf_round.c,v
retrieving revision 1.4
diff -u -p -r1.4 sf_round.c
--- libm/common/sf_round.c 8 Oct 2010 15:24:56 -0000 1.4
+++ libm/common/sf_round.c 8 Aug 2012 11:01:28 -0000
@@ -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;
Index: libm/math/e_atan2.c
===================================================================
RCS file: /cvs/src/src/newlib/libm/math/e_atan2.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 e_atan2.c
--- libm/math/e_atan2.c 17 Feb 2000 19:39:51 -0000 1.1.1.1
+++ libm/math/e_atan2.c 8 Aug 2012 11:01:29 -0000
@@ -73,7 +73,7 @@ pi_lo = 1.2246467991473531772E-16; /*
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 */
Index: libm/math/e_exp.c
===================================================================
RCS file: /cvs/src/src/newlib/libm/math/e_exp.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 e_exp.c
--- libm/math/e_exp.c 17 Feb 2000 19:39:51 -0000 1.1.1.1
+++ libm/math/e_exp.c 8 Aug 2012 11:01:29 -0000
@@ -109,7 +109,7 @@ P5 = 4.13813679705723846039e-08; /* 0
#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; /* 0
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;
Index: libm/math/e_pow.c
===================================================================
RCS file: /cvs/src/src/newlib/libm/math/e_pow.c,v
retrieving revision 1.5
diff -u -p -r1.5 e_pow.c
--- libm/math/e_pow.c 1 May 2007 18:42:15 -0000 1.5
+++ libm/math/e_pow.c 8 Aug 2012 11:01:29 -0000
@@ -120,9 +120,10 @@ ivln2_l = 1.92596299112661746887e-08;
/* 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
Index: libm/math/e_rem_pio2.c
===================================================================
RCS file: /cvs/src/src/newlib/libm/math/e_rem_pio2.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 e_rem_pio2.c
--- libm/math/e_rem_pio2.c 17 Feb 2000 19:39:51 -0000 1.1.1.1
+++ libm/math/e_rem_pio2.c 8 Aug 2012 11:01:29 -0000
@@ -89,7 +89,7 @@ pio2_3t = 8.47842766036889956997e-32; /
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;
Index: libm/math/ef_exp.c
===================================================================
RCS file: /cvs/src/src/newlib/libm/math/ef_exp.c,v
retrieving revision 1.2
diff -u -p -r1.2 ef_exp.c
--- libm/math/ef_exp.c 4 Apr 2001 13:30:59 -0000 1.2
+++ libm/math/ef_exp.c 8 Aug 2012 11:01:29 -0000
@@ -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;
Index: libm/math/ef_pow.c
===================================================================
RCS file: /cvs/src/src/newlib/libm/math/ef_pow.c,v
retrieving revision 1.4
diff -u -p -r1.4 ef_pow.c
--- libm/math/ef_pow.c 1 May 2007 18:42:15 -0000 1.4
+++ libm/math/ef_pow.c 8 Aug 2012 11:01:29 -0000
@@ -77,9 +77,10 @@ ivln2_l = 7.0526075433e-06; /* 0x36eca
/* 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
Index: libm/math/er_lgamma.c
===================================================================
RCS file: /cvs/src/src/newlib/libm/math/er_lgamma.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 er_lgamma.c
--- libm/math/er_lgamma.c 17 Feb 2000 19:39:51 -0000 1.1.1.1
+++ libm/math/er_lgamma.c 8 Aug 2012 11:01:29 -0000
@@ -216,7 +216,7 @@ static double zero= 0.00000000000000000
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);
Index: libm/math/erf_lgamma.c
===================================================================
RCS file: /cvs/src/src/newlib/libm/math/erf_lgamma.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 erf_lgamma.c
--- libm/math/erf_lgamma.c 17 Feb 2000 19:39:51 -0000 1.1.1.1
+++ libm/math/erf_lgamma.c 8 Aug 2012 11:01:29 -0000
@@ -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);
--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat
More information about the Newlib
mailing list