From 1f232abc8938cc1fe821a6a8504b3845bad89522 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 8 Aug 2012 11:04:18 +0000 Subject: 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. --- newlib/libc/stdlib/mbtowc_r.c | 2 ++ newlib/libc/stdlib/wctomb_r.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'newlib/libc/stdlib') diff --git a/newlib/libc/stdlib/mbtowc_r.c b/newlib/libc/stdlib/mbtowc_r.c index 7c6be69ea..d84fef5a2 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 98a0b74c0..13e1e4c36 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); -- cgit v1.2.3