From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2201) id 9496F3941C2D; Mon, 28 Sep 2020 13:12:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9496F3941C2D Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Jon TURNEY To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: avoid GCC 10 error with -Werror=narrowing X-Act-Checkin: newlib-cygwin X-Git-Author: Jon Turney X-Git-Refname: refs/heads/master X-Git-Oldrev: 3bb579a43c09d18217a19035054817591eb8d870 X-Git-Newrev: 129c9844a6c40d5dee658151c2ff2c461a5a1365 Message-Id: <20200928131237.9496F3941C2D@sourceware.org> Date: Mon, 28 Sep 2020 13:12:37 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2020 13:12:37 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=129c9844a6c40d5dee658151c2ff2c461a5a1365 commit 129c9844a6c40d5dee658151c2ff2c461a5a1365 Author: Jon Turney Date: Sat Sep 19 15:55:09 2020 +0100 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. Diff: --- winsup/cygwin/fhandler_console.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index 33e40a9f9..41cac37e6 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -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);