summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2020-09-19 15:55:09 +0100
committerKaz Kylheku <kaz@kylheku.com>2020-10-10 14:57:27 -0700
commitd5b7092445d076ab46d4495563cbc52a0450ae25 (patch)
tree949386c1c59317575187f6ae1a6526e76e0c93f3
parenta5f024b894511c911fbbf740af13e0c444659e3b (diff)
downloadcygnal-d5b7092445d076ab46d4495563cbc52a0450ae25.tar.gz
cygnal-d5b7092445d076ab46d4495563cbc52a0450ae25.tar.bz2
cygnal-d5b7092445d076ab46d4495563cbc52a0450ae25.zip
Cygwin: avoid GCC 10 error with -Werror=narrowing
Cherry-pick of 129c9844a6c40d5dee658151c2ff2c461a5a1365. ../../../../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.
-rw-r--r--winsup/cygwin/fhandler_console.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index 52741ce8b..afecb1294 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -2765,7 +2765,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;
@@ -2945,7 +2945,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);