From nobody Sat Apr 11 21:33:16 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772691488858593.6990838890354; Wed, 4 Mar 2026 22:18:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vy221-0008MH-4E; Thu, 05 Mar 2026 01:17:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vy21n-0008CN-Fb; Thu, 05 Mar 2026 01:17:45 -0500 Received: from www3579.sakura.ne.jp ([49.212.243.89]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vy21j-0002VX-Ut; Thu, 05 Mar 2026 01:17:43 -0500 Received: from h205.csg.ci.i.u-tokyo.ac.jp (h205.csg.ci.i.u-tokyo.ac.jp [133.11.54.205]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 6256HKcp066823 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 5 Mar 2026 15:17:23 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) DKIM-Signature: a=rsa-sha256; bh=En1yBiLIRHFeSQzQveGaZuLdWFSDfzKpc6bfIebW9wY=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Message-Id:To:Subject:Date; s=rs20250326; t=1772691443; v=1; b=rmBoxQnfX3FenTyBpZK0eCkF634qbTZ9EodZDvSDPGztSGsQE9BY+1flzoPeaTbr G3tg7PgKMMnjhK6Sd/BzY0UbJCU4fmNJCTr3Ab/GdtkpbuAEy2UnJoPZDXxpXCLx mdXqVUwbTysxXeOH7LDNPFBQ/NWsQ2gxvHOCdcN7NBubcoavV0K/Hq/k8KfI6NYl Ymc043QjDIONHpIv7eFlj5AAb82hvWXfcWWUF06YgG9D3m5ns2FmQgIRq2BRKb1q D0hyUmiLNsazGZxj+IIInCAxi3V32RMyVyrln8iFQ4uhEMknXaVfD89HfNm/sF3y /cdyqCTmHPDTBvWm9x/alg== From: Akihiko Odaki Date: Thu, 05 Mar 2026 15:16:44 +0900 Subject: [PATCH v4 1/4] contrib/elf2dmp: Grow PDB URL buffer MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260305-nvme-v4-1-b65b9de1839f@rsg.ci.i.u-tokyo.ac.jp> References: <20260305-nvme-v4-0-b65b9de1839f@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20260305-nvme-v4-0-b65b9de1839f@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: Viktor Prutyanov , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Markus Armbruster , Michael Roth , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Keith Busch , Klaus Jensen , Jesper Devantier , qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.15-dev-5ab4c Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=49.212.243.89; envelope-from=odaki@rsg.ci.i.u-tokyo.ac.jp; helo=www3579.sakura.ne.jp X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.703, RCVD_IN_VALIDITY_SAFE_BLOCKED=1.386, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1772691493205154100 The buffers used to construct a PDB URL overflow when the "age" property is greater than 0xf, so grow it. This also simplifies the logic of the URL construction to use one buffer instead of two to avoid the chore to synchronize the sizes of two buffers. Signed-off-by: Akihiko Odaki Reviewed-by: Peter Maydell --- contrib/elf2dmp/main.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c index d046a72ae67f..a62abadcc049 100644 --- a/contrib/elf2dmp/main.c +++ b/contrib/elf2dmp/main.c @@ -494,18 +494,6 @@ static bool pe_check_pdb_name(uint64_t base, void *sta= rt_addr, return !strcmp(pdb_name, PDB_NAME); } =20 -static void pe_get_pdb_symstore_hash(OMFSignatureRSDS *rsds, char *hash) -{ - sprintf(hash, "%.08x%.04x%.04x%.02x%.02x", rsds->guid.a, rsds->guid.b, - rsds->guid.c, rsds->guid.d[0], rsds->guid.d[1]); - hash +=3D 20; - for (unsigned int i =3D 0; i < 6; i++, hash +=3D 2) { - sprintf(hash, "%.02x", rsds->guid.e[i]); - } - - sprintf(hash, "%.01x", rsds->age); -} - int main(int argc, char *argv[]) { int err =3D 1; @@ -517,9 +505,7 @@ int main(int argc, char *argv[]) uint64_t KernBase; void *nt_start_addr =3D NULL; WinDumpHeader64 header; - char pdb_hash[34]; - char pdb_url[] =3D SYM_URL_BASE PDB_NAME - "/0123456789ABCDEF0123456789ABCDEFx/" PDB_NAME; + g_autofree char *pdb_url =3D NULL; struct pdb_reader pdb; uint64_t KdDebuggerDataBlock; KDDEBUGGER_DATA64 *kdbg; @@ -583,9 +569,21 @@ int main(int argc, char *argv[]) printf("KernBase =3D 0x%016"PRIx64", signature is \'%.2s\'\n", KernBas= e, (char *)nt_start_addr); =20 - pe_get_pdb_symstore_hash(&rsds, pdb_hash); + pdb_url =3D g_strdup_printf("%s" + "%.08x%.04x%.04x" + "%.02x%.02x" + "%.02x%.02x" + "%.02x%.02x" + "%.02x%.02x%.01x" + "%s", + SYM_URL_BASE PDB_NAME "/", + rsds.guid.a, rsds.guid.b, rsds.guid.c, + rsds.guid.d[0], rsds.guid.d[1], + rsds.guid.e[0], rsds.guid.e[1], + rsds.guid.e[2], rsds.guid.e[3], + rsds.guid.e[4], rsds.guid.e[5], rsds.age, + "/" PDB_NAME); =20 - sprintf(pdb_url, "%s%s/%s/%s", SYM_URL_BASE, PDB_NAME, pdb_hash, PDB_N= AME); printf("PDB URL is %s\n", pdb_url); =20 if (!download_url(PDB_NAME, pdb_url)) { --=20 2.53.0 From nobody Sat Apr 11 21:33:16 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772691527331364.97922611460774; Wed, 4 Mar 2026 22:18:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vy227-00007y-56; Thu, 05 Mar 2026 01:18:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vy21m-0008AX-HW; Thu, 05 Mar 2026 01:17:45 -0500 Received: from www3579.sakura.ne.jp ([49.212.243.89]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vy21j-0002VV-Op; Thu, 05 Mar 2026 01:17:41 -0500 Received: from h205.csg.ci.i.u-tokyo.ac.jp (h205.csg.ci.i.u-tokyo.ac.jp [133.11.54.205]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 6256HKcq066823 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 5 Mar 2026 15:17:23 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) DKIM-Signature: a=rsa-sha256; bh=zEGuWpwSPorKgdOr8uqnGxj5GoiSbQsHVJNvDM8QBj0=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Message-Id:To:Subject:Date; s=rs20250326; t=1772691443; v=1; b=JW6gjcl8KD9cHADl50P/DdJRuUA+HJkXGj9HI8USTxBe8XZ2CJ797GDa4OjpEJKh F4TDxrrsZ4NDv6xTm44J7tQBFIG9/Y2dS8A01OezJ75wL0BvXt7gANeEkOFIjs35 VTpw1yQhDIRfGZQh1STVA6gueG3w6rFjkSG1/y3C+2lqT+TxrlyLJ4X+BK/FTKsE tYaKyB2nJn3jTrJkVx8IwKQEnlbjnVHAGiCLWq7n70rp8IRE+PK1qYy+Le5HyN+B HNb2S3BGHCKhCMSlrcWtx6OmmXQC36eSGsZddDYep3yMKhwBJ7aOJAYCE3uMYXS6 S7QFGDmNCYQvsOA4Q3XMkQ== From: Akihiko Odaki Date: Thu, 05 Mar 2026 15:16:45 +0900 Subject: [PATCH v4 2/4] vfio/pci: Grow buffer in vfio_pci_host_match() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260305-nvme-v4-2-b65b9de1839f@rsg.ci.i.u-tokyo.ac.jp> References: <20260305-nvme-v4-0-b65b9de1839f@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20260305-nvme-v4-0-b65b9de1839f@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: Viktor Prutyanov , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Markus Armbruster , Michael Roth , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Keith Busch , Klaus Jensen , Jesper Devantier , qemu-block@nongnu.org, Akihiko Odaki , Alex Williamson X-Mailer: b4 0.15-dev-5ab4c Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=49.212.243.89; envelope-from=odaki@rsg.ci.i.u-tokyo.ac.jp; helo=www3579.sakura.ne.jp X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.703, RCVD_IN_VALIDITY_SAFE_BLOCKED=1.386, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1772691528980154100 Each field of PCIHostDeviceAddress is an unsigned int, therefore while a valid address is limited to 13 characters, an invalid address could exceed the specified format, up to: ffffffff:ffffffff:ffffffff.ffffffff This requires 36 characters with the terminator. Signed-off-by: Akihiko Odaki Reviewed-by: Alex Williamson --- hw/vfio/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index c89f3fbea348..94c174a773fb 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2739,7 +2739,7 @@ void vfio_pci_post_reset(VFIOPCIDevice *vdev) =20 bool vfio_pci_host_match(PCIHostDeviceAddress *addr, const char *name) { - char tmp[13]; + char tmp[36]; =20 sprintf(tmp, "%04x:%02x:%02x.%1x", addr->domain, addr->bus, addr->slot, addr->function); --=20 2.53.0 From nobody Sat Apr 11 21:33:16 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772691485226896.825624596446; Wed, 4 Mar 2026 22:18:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vy225-0008Ru-Su; Thu, 05 Mar 2026 01:18:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vy21n-0008CT-MU; Thu, 05 Mar 2026 01:17:45 -0500 Received: from www3579.sakura.ne.jp ([49.212.243.89]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vy21j-0002Va-VR; Thu, 05 Mar 2026 01:17:43 -0500 Received: from h205.csg.ci.i.u-tokyo.ac.jp (h205.csg.ci.i.u-tokyo.ac.jp [133.11.54.205]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 6256HKcr066823 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 5 Mar 2026 15:17:23 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) DKIM-Signature: a=rsa-sha256; bh=PO1Qslwg9u04nJdizAJfbxCF6DX96er2JVAT/7p3EVU=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Message-Id:To:Subject:Date; s=rs20250326; t=1772691444; v=1; b=rPtdvqGGLXBY+HAMb5cp3a5nV7czwyK8l5kX62mNwQkmGfK4d/gGB9w++uQdRDUf M8TD9n7w9iIK9JX6feDZnC9NPQ8NKGZPlY9ARxEFG5/OIT0BEB3c6/ITVICOBTnI gnGUFU/oE9enTGsKUTi+1guohH2JNMx5T476LMMVgxrnF5jAaRZ1U8aWgGNlN8Xk JMNSzHgnKlnEc3tUwDr5D3QO/HT/a32ZKQ7/KwDFN8nRjVXwgob147T3u1351qbc riRgohgTPvn8SVPt+6lOhu5D+yg5AEypJi6nd5d022JUYIYvRPbVhJc1UVh02Ua+ 2mhLLj/INca1qfeRKN9Oyw== From: Akihiko Odaki Date: Thu, 05 Mar 2026 15:16:46 +0900 Subject: [PATCH v4 3/4] tests: Clean up double comparisons to avoid compiler warning MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260305-nvme-v4-3-b65b9de1839f@rsg.ci.i.u-tokyo.ac.jp> References: <20260305-nvme-v4-0-b65b9de1839f@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20260305-nvme-v4-0-b65b9de1839f@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: Viktor Prutyanov , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Markus Armbruster , Michael Roth , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Keith Busch , Klaus Jensen , Jesper Devantier , qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.15-dev-5ab4c Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=49.212.243.89; envelope-from=odaki@rsg.ci.i.u-tokyo.ac.jp; helo=www3579.sakura.ne.jp X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.703, RCVD_IN_VALIDITY_SAFE_BLOCKED=1.386, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1772691513559158500 To enable -Wformat-overflow=3D2, we need to clean up a couple of false positives: [2/5] Compiling C object tests/unit/test-qobject-output-visitor.p/test-qobj= ect-output-visitor.c.o FAILED: tests/unit/test-qobject-output-visitor.p/test-qobject-output-visito= r.c.o cc -Itests/unit/test-qobject-output-visitor.p -Itests/unit -I../tests/unit = -I. -Iqapi -Itrace -Iui -Iui/shader -Itests -Itests/include -I/usr/include/= glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/sysprof-6 -fdiagnosti= cs-color=3Dauto -Wall -Winvalid-pch -Werror -std=3Dgnu11 -O2 -g -D_GNU_SOUR= CE -D_FILE_OFFSET_BITS=3D64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-c= ommon -fwrapv -ftrivial-auto-var-init=3Dzero -fzero-call-used-regs=3Dused-g= pr -fsanitize=3Daddress -fstack-protector-strong -fsanitize=3Dundefined -We= mpty-body -Wendif-labels -Wexpansion-to-defined -Wformat-overflow=3D2 -Wfor= mat-security -Wformat-y2k -Wignored-qualifiers -Wimplicit-fallthrough=3D2 -= Winit-self -Wmissing-format-attribute -Wmissing-prototypes -Wnested-externs= -Wold-style-declaration -Wold-style-definition -Wredundant-decls -Wshadow= =3Dlocal -Wstrict-prototypes -Wtype-limits -Wundef -Wvla -Wwrite-strings -W= no-missing-include-dirs -Wno-psabi -Wno-shift-negative-value -isystem /home= /me/q/var/qemu/linux-headers -isyst! em linux-headers -iquote . -iquote /home/me/q/var/qemu -iquote /home/me/q/= var/qemu/include -iquote /home/me/q/var/qemu/host/include/aarch64 -iquote /= home/me/q/var/qemu/host/include/generic -iquote /home/me/q/var/qemu/tcg/aar= ch64 -pthread -fPIE -MD -MQ tests/unit/test-qobject-output-visitor.p/test-q= object-output-visitor.c.o -MF tests/unit/test-qobject-output-visitor.p/test= -qobject-output-visitor.c.o.d -o tests/unit/test-qobject-output-visitor.p/t= est-qobject-output-visitor.c.o -c ../tests/unit/test-qobject-output-visitor= .c ../tests/unit/test-qobject-output-visitor.c: In function =E2=80=98test_visi= tor_out_list_struct=E2=80=99: ../tests/unit/test-qobject-output-visitor.c:577:28: error: =E2=80=98%.6f=E2= =80=99 directive writing between 3 and 317 bytes into a region of size 32 [= -Werror=3Dformat-overflow=3D] 577 | sprintf(expected, "%.6f", (double)i / 3); | ^~~~ ../tests/unit/test-qobject-output-visitor.c:577:27: note: assuming directiv= e output of 8 bytes 577 | sprintf(expected, "%.6f", (double)i / 3); | ^~~~~~ In file included from /usr/include/stdio.h:970, from /home/me/q/var/qemu/include/qemu/osdep.h:114, from ../tests/unit/test-qobject-output-visitor.c:13: In function =E2=80=98sprintf=E2=80=99, inlined from =E2=80=98test_visitor_out_list_struct=E2=80=99 at ../tests= /unit/test-qobject-output-visitor.c:577:9: /usr/include/bits/stdio2.h:30:10: note: =E2=80=98__builtin___sprintf_chk=E2= =80=99 output between 4 and 318 bytes into a destination of size 32 30 | return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 31 | __glibc_objsize (__s), __fmt, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 32 | __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~ ../tests/unit/test-qobject-output-visitor.c: In function =E2=80=98test_visi= tor_out_list_struct=E2=80=99: ../tests/unit/test-qobject-output-visitor.c:578:26: error: =E2=80=98%.6f=E2= =80=99 directive writing between 3 and 317 bytes into a region of size 32 [= -Werror=3Dformat-overflow=3D] 578 | sprintf(actual, "%.6f", qnum_get_double(qvalue)); | ^~~~ ../tests/unit/test-qobject-output-visitor.c:578:25: note: assuming directiv= e output of 8 bytes 578 | sprintf(actual, "%.6f", qnum_get_double(qvalue)); | ^~~~~~ In function =E2=80=98sprintf=E2=80=99, inlined from =E2=80=98test_visitor_out_list_struct=E2=80=99 at ../tests= /unit/test-qobject-output-visitor.c:578:9: /usr/include/bits/stdio2.h:30:10: note: =E2=80=98__builtin___sprintf_chk=E2= =80=99 output between 4 and 318 bytes into a destination of size 32 30 | return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 31 | __glibc_objsize (__s), __fmt, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 32 | __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors These buffers cannot actually overflow because the doubles are between 0 and 31.0/3 inclusive. However, formatting doubles just to compare them is silly. Compare them directly instead. To avoid potential rounding trouble, change the numbers tested to be representable exactly in double. Signed-off-by: Akihiko Odaki Reviewed-by: Markus Armbruster --- tests/unit/test-qobject-input-visitor.c | 8 ++------ tests/unit/test-qobject-output-visitor.c | 7 ++----- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/tests/unit/test-qobject-input-visitor.c b/tests/unit/test-qobj= ect-input-visitor.c index 84bdcdf702e0..beee11db4e47 100644 --- a/tests/unit/test-qobject-input-visitor.c +++ b/tests/unit/test-qobject-input-visitor.c @@ -500,7 +500,7 @@ static void test_visitor_in_list_struct(TestInputVisito= rData *data, g_string_append_printf(json, "'number': ["); sep =3D ""; for (i =3D 0; i < 32; i++) { - g_string_append_printf(json, "%s%f", sep, (double)i / 3); + g_string_append_printf(json, "%s%f", sep, (double)i / FLT_RADIX); sep =3D ", "; } g_string_append_printf(json, "], "); @@ -583,11 +583,7 @@ static void test_visitor_in_list_struct(TestInputVisit= orData *data, =20 i =3D 0; for (num_list =3D arrs->number; num_list; num_list =3D num_list->next)= { - char expected[32], actual[32]; - - sprintf(expected, "%.6f", (double)i / 3); - sprintf(actual, "%.6f", num_list->value); - g_assert_cmpstr(expected, =3D=3D, actual); + g_assert_cmpfloat(num_list->value, =3D=3D, (double)i / FLT_RADIX); i++; } =20 diff --git a/tests/unit/test-qobject-output-visitor.c b/tests/unit/test-qob= ject-output-visitor.c index 407ab9ed505a..3c47b28f6638 100644 --- a/tests/unit/test-qobject-output-visitor.c +++ b/tests/unit/test-qobject-output-visitor.c @@ -538,7 +538,7 @@ static void test_visitor_out_list_struct(TestOutputVisi= torData *data, } =20 for (i =3D 31; i >=3D 0; i--) { - QAPI_LIST_PREPEND(arrs->number, (double)i / 3); + QAPI_LIST_PREPEND(arrs->number, (double)i / FLT_RADIX); } =20 for (i =3D 31; i >=3D 0; i--) { @@ -571,12 +571,9 @@ static void test_visitor_out_list_struct(TestOutputVis= itorData *data, i =3D 0; QLIST_FOREACH_ENTRY(qlist, e) { QNum *qvalue =3D qobject_to(QNum, qlist_entry_obj(e)); - char expected[32], actual[32]; =20 g_assert(qvalue); - sprintf(expected, "%.6f", (double)i / 3); - sprintf(actual, "%.6f", qnum_get_double(qvalue)); - g_assert_cmpstr(actual, =3D=3D, expected); + g_assert_cmpfloat(qnum_get_double(qvalue), =3D=3D, (double)i / FLT= _RADIX); i++; } =20 --=20 2.53.0 From nobody Sat Apr 11 21:33:16 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=reject dis=none) header.from=rsg.ci.i.u-tokyo.ac.jp Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772691543159587.1713755200211; Wed, 4 Mar 2026 22:19:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vy225-0008S2-Tx; Thu, 05 Mar 2026 01:18:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vy21n-0008CM-EI; Thu, 05 Mar 2026 01:17:45 -0500 Received: from www3579.sakura.ne.jp ([49.212.243.89]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vy21j-0002VW-UM; Thu, 05 Mar 2026 01:17:43 -0500 Received: from h205.csg.ci.i.u-tokyo.ac.jp (h205.csg.ci.i.u-tokyo.ac.jp [133.11.54.205]) (authenticated bits=0) by www3579.sakura.ne.jp (8.16.1/8.16.1) with ESMTPSA id 6256HKcs066823 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 5 Mar 2026 15:17:24 +0900 (JST) (envelope-from odaki@rsg.ci.i.u-tokyo.ac.jp) DKIM-Signature: a=rsa-sha256; bh=FW1M35ADo1rOGTkjkUKBAtfBI7U6bavuPH5VmSHyiJw=; c=relaxed/relaxed; d=rsg.ci.i.u-tokyo.ac.jp; h=From:Message-Id:To:Subject:Date; s=rs20250326; t=1772691444; v=1; b=eloQDTmkDcdpTPIUPQgN0sk6Fh/C62wx9MCo/qY8Vbm9ju3pjWiv9Um25BFuMcpO cIZ03kRx7wiYp72LnwSS7ZQYEPCOri3/DvmWaBNxSHfnciyFro2veFEMw1dOjE+Z oFRqOE3I0whWXtXmw2b3ltdV6Wh8MwUZfcqwKY/8+fXlAyj0kWshUa2d1rw5I68L FCsDKpkCyCJU8inR535G6iGxGWdszNaSXSJgoK3ZcXaReyyNlAkKss/YrDXF+tJ4 mg4oUxR0iTwlrQA7kmLPP/k25n2i7x5/BL4YvAXuX04NVFTimxeP1l2cnlIYw7oR 9yAkMQfeYhG7YBJE3k7cFg== From: Akihiko Odaki Date: Thu, 05 Mar 2026 15:16:47 +0900 Subject: [PATCH v4 4/4] meson: Add -Wformat-overflow=2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260305-nvme-v4-4-b65b9de1839f@rsg.ci.i.u-tokyo.ac.jp> References: <20260305-nvme-v4-0-b65b9de1839f@rsg.ci.i.u-tokyo.ac.jp> In-Reply-To: <20260305-nvme-v4-0-b65b9de1839f@rsg.ci.i.u-tokyo.ac.jp> To: qemu-devel@nongnu.org Cc: Viktor Prutyanov , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Markus Armbruster , Michael Roth , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Keith Busch , Klaus Jensen , Jesper Devantier , qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.15-dev-5ab4c Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=49.212.243.89; envelope-from=odaki@rsg.ci.i.u-tokyo.ac.jp; helo=www3579.sakura.ne.jp X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.703, RCVD_IN_VALIDITY_SAFE_BLOCKED=1.386, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1772691545081154100 https://gcc.gnu.org/onlinedocs/gcc-15.2.0/gcc/Warning-Options.html > Level 2 warns also about calls that might overflow the destination > buffer given an argument of sufficient length or magnitude. At level > 2, unknown numeric arguments are assumed to have the minimum > representable value for signed types with a precision greater than 1, > and the maximum representable value otherwise. Unknown string > arguments whose length cannot be assumed to be bounded either by the > directive=E2=80=99s precision, or by a finite set of string literals they= may > evaluate to, or the character array they may point to, are assumed to > be 1 character long. Signed-off-by: Akihiko Odaki Reviewed-by: Peter Maydell --- meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/meson.build b/meson.build index 414c8ea7e280..cf50bc492f9c 100644 --- a/meson.build +++ b/meson.build @@ -692,6 +692,7 @@ warn_flags =3D [ '-Wempty-body', '-Wendif-labels', '-Wexpansion-to-defined', + '-Wformat-overflow=3D2', '-Wformat-security', '-Wformat-y2k', '-Wignored-qualifiers', --=20 2.53.0