From nobody Mon Feb 9 21:40:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526797578018162.2251545140192; Sat, 19 May 2018 23:26:18 -0700 (PDT) Received: from localhost ([::1]:45317 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fKHnF-0001NS-IC for importer@patchew.org; Sun, 20 May 2018 02:26:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44886) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fKHlW-0007my-Qz for qemu-devel@nongnu.org; Sun, 20 May 2018 02:24:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fKHlT-0008Jq-UQ for qemu-devel@nongnu.org; Sun, 20 May 2018 02:24:22 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:45661) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fKHlT-0008JL-JL; Sun, 20 May 2018 02:24:19 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id E9D8841129; Sun, 20 May 2018 09:24:18 +0300 (MSK) Received: from tls.msk.ru (mjt.vpn.tls.msk.ru [192.168.177.99]) by tsrv.corpit.ru (Postfix) with SMTP id ACFF210C7; Sun, 20 May 2018 09:15:13 +0300 (MSK) Received: (nullmailer pid 7399 invoked by uid 1000); Sun, 20 May 2018 06:15:11 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Date: Sun, 20 May 2018 09:15:01 +0300 Message-Id: <54be4c42b2796ca6054cd1539d3ad4486447c789.1526796813.git.mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 86.62.121.231 Subject: [Qemu-devel] [PULL 15/22] hw/timer/mt48t59: Fix bit-rotten NVRAM_PRINTF format strings 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: qemu-trivial@nongnu.org, Thomas Huth , Michael Tokarev Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth When compiling with NVRAM_PRINTF enabled, gcc currently bails out with: CC hw/timer/m48t59.o CC hw/timer/m48t59-isa.o hw/timer/m48t59.c: In function =E2=80=98NVRAM_writeb=E2=80=99: hw/timer/m48t59.c:460:5: error: format =E2=80=98%x=E2=80=99 expects argumen= t of type =E2=80=98unsigned int=E2=80=99, but argument 3 has type =E2=80=98= hwaddr=E2=80=99 [-Werror=3Dformat=3D] NVRAM_PRINTF("%s: 0x%08x =3D> 0x%08x\n", __func__, addr, val); ^ hw/timer/m48t59.c:460:5: error: format =E2=80=98%x=E2=80=99 expects argumen= t of type =E2=80=98unsigned int=E2=80=99, but argument 4 has type =E2=80=98= uint64_t=E2=80=99 [-Werror=3Dformat=3D] hw/timer/m48t59.c: In function =E2=80=98NVRAM_readb=E2=80=99: hw/timer/m48t59.c:492:5: error: format =E2=80=98%x=E2=80=99 expects argumen= t of type =E2=80=98unsigned int=E2=80=99, but argument 3 has type =E2=80=98= hwaddr=E2=80=99 [-Werror=3Dformat=3D] NVRAM_PRINTF("%s: 0x%08x <=3D 0x%08x\n", __func__, addr, retval); Fix it by using the correct format strings and while we're at it, also change the definition of NVRAM_PRINTF so that this can not bit-rot so easily again. Signed-off-by: Thomas Huth Reviewed-by: Mark Cave-Ayland Signed-off-by: Michael Tokarev --- hw/timer/m48t59-internal.h | 9 +++------ hw/timer/m48t59.c | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/hw/timer/m48t59-internal.h b/hw/timer/m48t59-internal.h index 32ae957805..d0f0caf3c7 100644 --- a/hw/timer/m48t59-internal.h +++ b/hw/timer/m48t59-internal.h @@ -25,13 +25,10 @@ #ifndef HW_M48T59_INTERNAL_H #define HW_M48T59_INTERNAL_H 1 =20 -//#define DEBUG_NVRAM +#define M48T59_DEBUG 0 =20 -#if defined(DEBUG_NVRAM) -#define NVRAM_PRINTF(fmt, ...) do { printf(fmt , ## __VA_ARGS__); } while = (0) -#else -#define NVRAM_PRINTF(fmt, ...) do { } while (0) -#endif +#define NVRAM_PRINTF(fmt, ...) do { \ + if (M48T59_DEBUG) { printf(fmt , ## __VA_ARGS__); } } while (0) =20 /* * The M48T02, M48T08 and M48T59 chips are very similar. The newer '59 has diff --git a/hw/timer/m48t59.c b/hw/timer/m48t59.c index 742c576443..f2991762ab 100644 --- a/hw/timer/m48t59.c +++ b/hw/timer/m48t59.c @@ -456,7 +456,7 @@ static void NVRAM_writeb(void *opaque, hwaddr addr, uin= t64_t val, { M48t59State *NVRAM =3D opaque; =20 - NVRAM_PRINTF("%s: 0x%08x =3D> 0x%08x\n", __func__, addr, val); + NVRAM_PRINTF("%s: 0x%"HWADDR_PRIx" =3D> 0x%"PRIx64"\n", __func__, addr= , val); switch (addr) { case 0: NVRAM->addr &=3D ~0x00FF; @@ -488,7 +488,7 @@ static uint64_t NVRAM_readb(void *opaque, hwaddr addr, = unsigned size) retval =3D -1; break; } - NVRAM_PRINTF("%s: 0x%08x <=3D 0x%08x\n", __func__, addr, retval); + NVRAM_PRINTF("%s: 0x%"HWADDR_PRIx" <=3D 0x%08x\n", __func__, addr, ret= val); =20 return retval; } --=20 2.11.0