From nobody Tue May 7 05:41:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1574300423; cv=none; d=zoho.com; s=zohoarc; b=G3+1Zllnc8bJN60aLpozjrTzMkLszzpR3pwnt+49MSoc1VOFNv+QNbEV7WnQuuAp6P8EDTl2X1JuVWnxe7y1UAlhUUkN0uR3sHDjXtVCyTz3G5VpcZ1q8xTqrtO+mV0mV1qQRnO8R8m+e96OUiZWHZgR48tDHiGosGCzjx/nuhw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574300423; h=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=G7x+0l0MGkhypHBusSieelbqM+mMXLIb2T8PK21/BIw=; b=Bf80CDohqiR0CIpOyZyyIp9yofdX84eHSu5VNP6/+Bn4NZzclm+XviU3mnpr8OSMntXHAL4Fj1CNkOW9LGLxmISe0oo1Dtg69vg4Wv/nnvfCJBoV5850jHA8jOUp+vYIzZe9N2Bfn8iMPwrRzZfo+UX6WsNJcxDsZ7HtDX89ktE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1574300422567445.61159131014256; Wed, 20 Nov 2019 17:40:22 -0800 (PST) Received: from localhost ([::1]:35650 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXbSD-0000ve-Q4 for importer@patchew.org; Wed, 20 Nov 2019 20:40:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38324) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXbRA-0008OP-JC for qemu-devel@nongnu.org; Wed, 20 Nov 2019 20:39:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXbR8-0006SU-J2 for qemu-devel@nongnu.org; Wed, 20 Nov 2019 20:39:12 -0500 Received: from ozlabs.org ([203.11.71.1]:59921) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iXbR4-0006OQ-KA; Wed, 20 Nov 2019 20:39:07 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 47JMfZ4dplz9sPn; Thu, 21 Nov 2019 12:39:02 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1574300342; bh=JIfsApD1YfZ/bDz9LeRPQyITPIdEKbfk9wNA+Pc165I=; h=From:To:Cc:Subject:Date:From; b=CpJFW+/eB542mN3g2/u4O3uCRcVAL1kE2T1R+tpGV0g+Mg0YlWGRJPurUI8SS/FFw 3x7r92N81sNWW7657+k56qtdx1I081EkiqrlJXgvKni3AYsFeFx2v5Uw4OPCgGH1Wv /Dzkb7owmxAbBEjDPlhJB08xhjjvP35UCwJF8+aA= From: David Gibson To: qemu-devel@nongnu.org Subject: [PATCH v2] exynos4210_gic: Suppress gcc9 format-truncation warnings Date: Thu, 21 Nov 2019 12:38:59 +1100 Message-Id: <20191121013859.287372-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: Igor Mitsyanko , Peter Maydell , qemu-arm@nongnu.org, 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 Changes since v1: * Used an assert to hint the compiler, instead of increasing the buffer size. Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/intc/exynos4210_gic.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c index a1b699b6ba..ed4d8482e3 100644 --- a/hw/intc/exynos4210_gic.c +++ b/hw/intc/exynos4210_gic.c @@ -314,6 +314,14 @@ static void exynos4210_gic_realize(DeviceState *dev, E= rror **errp) 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(i <=3D EXYNOS4210_NCPUS); + /* 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