From nobody Fri Apr 26 06:54:51 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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 ARC-Seal: i=1; a=rsa-sha256; t=1575266973; cv=none; d=zohomail.com; s=zohoarc; b=hVUtRyI3rreuUHXQ7k3ffqtk710R0s5wnoatRaqPt/dMb/wrQRXUEIr+s+fIMKGW0J6ARDafoZXhDjOn38lnfdRXANhutAKkrQQb+szd/O4ZjKJKtARwOVpMpVpWyb9hhssxaYTMkna61ZxknlzzGVdN+xwXD84kO7fpalHFGOs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575266973; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=LVd/i8HW09e/vdFnL8QhLU0pyTvDK6DiGpY/Dul0znU=; b=ngTNmY0LdAji7s3AuZKnqbewXe7xPX/FN9vTf6DFKj5qILu0zsp+99WeYIApmrMMwLWxr8h17vwuFjWN4k1Tbf7W4YDcUfYoGP3j2ILXJptaqb25jR9FYGGXtpLFPGE6NIqG0Gs9v64WEpgLFMsZoottuwVXDNdbu05EHdSn1tA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1575266973200779.81909923728; Sun, 1 Dec 2019 22:09:33 -0800 (PST) Received: from localhost ([::1]:59310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ibetm-00054a-U8 for importer@patchew.org; Mon, 02 Dec 2019 01:09:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58147) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ibesf-0004Vv-Cz for qemu-devel@nongnu.org; Mon, 02 Dec 2019 01:08:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ibesd-00016o-Th for qemu-devel@nongnu.org; Mon, 02 Dec 2019 01:08:21 -0500 Received: from ozlabs.org ([203.11.71.1]:53979) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ibesZ-00016B-8u; Mon, 02 Dec 2019 01:08:16 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 47RF621gLzz9sPL; Mon, 2 Dec 2019 17:08:10 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1575266890; bh=USu8JlsY/OzHA2YhXxTPxDDMZBunzRsn+270mXy38Zo=; h=From:To:Cc:Subject:Date:From; b=bi3XDkPwIZaOws/HGq/oT54ob58swfTjE0sP4YauSYuvixDLssPVIE1tKsGEYBcMJ TcWo7VfXn6a1tbmIzSpeW44GVJQYIZBwLMVJhCGTzM4LoTpcrnMQExbq2XR7JCzJCt mcZ+GuU/2FAVchKJPlHlrdjXqvsBtUQzN/lAns/Q= From: David Gibson To: peter.maydell@linaro.org Subject: [PATCHv3] exynos4210_gic: Suppress gcc9 format-truncation warnings Date: Mon, 2 Dec 2019 17:08:06 +1100 Message-Id: <20191202060806.77968-1-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.23.0 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: 203.11.71.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: i.mitsyanko@gmail.com, richard.henderson@linaro.org, qemu-devel@nongnu.org, qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" exynos4210_gic_realize() prints the number of cpus into some temporary buffers, but it only allows 3 bytes space for it. That's plenty: existing machines will only ever set this value to EXYNOS4210_NCPUS (2). But the compiler can't always figure that out, so some[*] gcc9 versions emit -Wformat-truncation warnings. We can fix that by hinting the constraint to the compiler with a suitably placed assert(). [*] The bizarre thing here, is that I've long gotten these warnings compiling in a 32-bit x86 container as host - Fedora 30 with gcc-9.2.1-1.fc30.i686 - but it compiles just fine on my normal x86_64 host - Fedora 30 with and gcc-9.2.1-1.fc30.x86_64. Signed-off-by: David Gibson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Peter, up to you if you squeeze this in for qemu-4.2 or leave it until 5.0 Changes since v2: * Moved the assert outside the for loop using a trick suggested by Richard Henderson Changes since v1: * Used an assert to hint the compiler, instead of increasing the buffer size. Reviewed-by: Richard Henderson --- hw/intc/exynos4210_gic.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c index a1b699b6ba..ddd006aca6 100644 --- a/hw/intc/exynos4210_gic.c +++ b/hw/intc/exynos4210_gic.c @@ -293,6 +293,7 @@ static void exynos4210_gic_realize(DeviceState *dev, Er= ror **errp) char cpu_alias_name[sizeof(cpu_prefix) + 3]; char dist_alias_name[sizeof(cpu_prefix) + 3]; SysBusDevice *gicbusdev; + uint32_t n =3D s->num_cpu; uint32_t i; =20 s->gic =3D qdev_create(NULL, "arm_gic"); @@ -313,7 +314,14 @@ static void exynos4210_gic_realize(DeviceState *dev, E= rror **errp) memory_region_init(&s->dist_container, obj, "exynos4210-dist-container= ", EXYNOS4210_EXT_GIC_DIST_REGION_SIZE); =20 - for (i =3D 0; i < s->num_cpu; i++) { + /* + * This clues in gcc that our on-stack buffers do, in fact have + * enough room for the cpu numbers. gcc 9.2.1 on 32-bit x86 + * doesn't figure this out, otherwise and gives spurious warnings. + */ + assert(n <=3D EXYNOS4210_NCPUS); + for (i =3D 0; i < n; i++) { + /* Map CPU interface per SMP Core */ sprintf(cpu_alias_name, "%s%x", cpu_prefix, i); memory_region_init_alias(&s->cpu_alias[i], obj, --=20 2.23.0