From patchwork Mon May 27 14:25:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 10963249 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 42E741390 for ; Mon, 27 May 2019 14:26:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F4C2287C3 for ; Mon, 27 May 2019 14:26:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23C8A28B50; Mon, 27 May 2019 14:26:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7A6BA287C3 for ; Mon, 27 May 2019 14:26:31 +0000 (UTC) Received: from localhost ([127.0.0.1]:46633 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVGa6-0003rJ-7x for patchwork-qemu-devel@patchwork.kernel.org; Mon, 27 May 2019 10:26:30 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45524) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVGZV-0003Uf-61 for qemu-devel@nongnu.org; Mon, 27 May 2019 10:25:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVGZU-0005f7-7M for qemu-devel@nongnu.org; Mon, 27 May 2019 10:25:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33480) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hVGZT-0005dR-Va for qemu-devel@nongnu.org; Mon, 27 May 2019 10:25:52 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 412FE307D860 for ; Mon, 27 May 2019 14:25:45 +0000 (UTC) Received: from localhost (unknown [10.40.205.13]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 99DB010027B6; Mon, 27 May 2019 14:25:42 +0000 (UTC) From: Max Reitz To: qemu-devel@nongnu.org Date: Mon, 27 May 2019 16:25:40 +0200 Message-Id: <20190527142540.23255-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Mon, 27 May 2019 14:25:50 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] ui/curses: Fix build with -m32 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP wchar_t may resolve to be an unsigned long on 32-bit architectures. Using the %x conversion specifier will then give a compiler warning: ui/curses.c: In function ‘get_ucs’: ui/curses.c:492:49: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 3 has type ‘wchar_t’ {aka ‘long int’} [-Werror=format=] 492 | fprintf(stderr, "Could not convert 0x%04x " | ~~~^ | | | unsigned int | %04lx 493 | "from wchar_t to a multibyte character: %s\n", 494 | wch, strerror(errno)); | ~~~ | | | wchar_t {aka long int} ui/curses.c:504:49: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 3 has type ‘wchar_t’ {aka ‘long int’} [-Werror=format=] 504 | fprintf(stderr, "Could not convert 0x%04x " | ~~~^ | | | unsigned int | %04lx 505 | "from a multibyte character to UCS-2 : %s\n", 506 | wch, strerror(errno)); | ~~~ | | | wchar_t {aka long int} Fix this by casting the wchar_t value to an unsigned long and using %lx as the conversion specifier. Fixes: b7b664a4fe9a955338f2e11a0f7433b29c8cbad0 Signed-off-by: Max Reitz Reviewed-by: Samuel Thibault --- ui/curses.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/curses.c b/ui/curses.c index 1f3fcabb00..e9319eb8ae 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -489,9 +489,9 @@ static uint16_t get_ucs(wchar_t wch, iconv_t conv) memset(&ps, 0, sizeof(ps)); ret = wcrtomb(mbch, wch, &ps); if (ret == -1) { - fprintf(stderr, "Could not convert 0x%04x " + fprintf(stderr, "Could not convert 0x%04lx " "from wchar_t to a multibyte character: %s\n", - wch, strerror(errno)); + (unsigned long)wch, strerror(errno)); return 0xFFFD; } @@ -501,9 +501,9 @@ static uint16_t get_ucs(wchar_t wch, iconv_t conv) such = sizeof(uch); if (iconv(conv, &pmbch, &smbch, &puch, &such) == (size_t) -1) { - fprintf(stderr, "Could not convert 0x%04x " + fprintf(stderr, "Could not convert 0x%04lx " "from a multibyte character to UCS-2 : %s\n", - wch, strerror(errno)); + (unsigned long)wch, strerror(errno)); return 0xFFFD; }