4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-19 12:59:21 +08:00

Cygwin: avoid GCC 10 error with -Werror=narrowing

../../../../src/winsup/cygwin/fhandler_console.cc: In member function 'const unsigned char* fhandler_console::write_normal(const unsigned char*, const unsigned char*)':
../../../../src/winsup/cygwin/fhandler_console.cc:2782:8: error: narrowing conversion of '-2' from 'int' to 'long unsigned int' [-Wnarrowing]
../../../../src/winsup/cygwin/fhandler_console.cc:2786:8: error: narrowing conversion of '-1' from 'int' to 'long unsigned int' [-Wnarrowing]
../../../../src/winsup/cygwin/fhandler_console.cc:2836:8: error: narrowing conversion of '-2' from 'int' to 'long unsigned int' [-Wnarrowing]
../../../../src/winsup/cygwin/fhandler_console.cc:2840:8: error: narrowing conversion of '-1' from 'int' to 'long unsigned int' [-Wnarrowing]

A mbtowc_p function returns an int, so that seems the correct type to use here.
This commit is contained in:
Jon Turney 2020-09-19 15:55:09 +01:00
parent 3bb579a43c
commit 129c9844a6
No known key found for this signature in database
GPG Key ID: C7C86F0370285C81

View File

@ -2759,7 +2759,7 @@ fhandler_console::write_normal (const unsigned char *src,
DWORD done;
DWORD buf_len;
const unsigned char *found = src;
size_t ret;
int ret;
mbstate_t ps;
mbtowc_p f_mbtowc;
@ -2938,7 +2938,7 @@ do_print:
{
ret = __utf8_mbtowc (_REENT, NULL, (const char *) found + 1,
end - found - 1, &ps);
if (ret != (size_t) -1)
if (ret != -1)
while (ret-- > 0)
{
WCHAR w = *(found + 1);