Received: by 2002:a19:6911:0:0:0:0:0 with SMTP id e17csp1519306lfc; Tue, 19 Nov 2019 21:27:25 -0800 (PST) X-Google-Smtp-Source: APXvYqyx1XozYcfZlgbKwEepQkG7pQMeFgoLiIyZUenZTt6G4xL+7WDx3LGIER1uv692ygR9GI1Q X-Received: by 2002:a17:906:1da1:: with SMTP id u1mr2580651ejh.275.1574227644973; Tue, 19 Nov 2019 21:27:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574227644; cv=none; d=google.com; s=arc-20160816; b=jJZkEpa6+vHAfiFQvPJI0ZYUJ1yzahUkuAlkGL1UvsZPkM/Lk77gkTK/q0fQWeSbZV ms3zRh9eHh8+66Ive+Z0pLrvKENg3y8b8UeB+YczCqVbjvFZYX56M58GqN2hYtKjDGdT ONOsbGycsqK7YmN4IS4IDmHOSAhm/X7wqYUtI2va74xVcpI2jR1iLO2UiceGYgzFIgry 26ITIIqmJQJn6IX9n8Plg51b9xt1GggXD6I7Q+cbOeiJFeUKlXDeuG86wvWap7YAKBi1 VlV3CRjgrCLpk6Jg3WkpUOLOSXleBota3E5f1CsUbr1oou0sXP3bgP2+MNfDRdy3hB+x /c7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:to :from:date:dkim-signature; bh=1HIrtJHgiIXW8WKXJyR2AkoPQwdNbPfan5ykUGMDr2Y=; b=xFAVeNLWsaqrw859rYTPW4wq5y3AGNADubsZT5a0oN08zQxVytc4m9y2GVY3miTpD+ eLzBDjBfdZkzszlR/O1CRvdMWLxGxxLuk6EG0TU/EmtYSkD/nWupu3tEb7NBJhcMpewh phm8du+hwqK4M8L0VpFaeC9Zcjq28AhM7HF30k1Bul3XCY7T4i6OXm0klhF27vONGD1x IK6F39R4kAPPu5fBg8CuIyXi8cdpvwd2y/0uzbBf1z3NiAM9a508ODsGDSbXkJnG6Iv1 0vgcbWCIWLXjGBSmhT8p6lpbyh3wLyAoR+7JJC3rWEZ3q8ixZNpIc79UsHM0bEOmchae XN8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gibson.dropbear.id.au header.s=201602 header.b=MQzQ9yVM; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b5si17143111edq.173.2019.11.19.21.27.24 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Nov 2019 21:27:24 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@gibson.dropbear.id.au header.s=201602 header.b=MQzQ9yVM; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org" Received: from localhost ([::1]:53758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXIWS-0007Kz-1d for alex.bennee@linaro.org; Wed, 20 Nov 2019 00:27:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38460) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXIWI-0007JR-Mb for qemu-arm@nongnu.org; Wed, 20 Nov 2019 00:27:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXIWG-0007iP-3F for qemu-arm@nongnu.org; Wed, 20 Nov 2019 00:27:14 -0500 Received: from bilbo.ozlabs.org ([2401:3900:2:1::2]:40883 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iXIWF-0007fu-9u; Wed, 20 Nov 2019 00:27:12 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 47HrmB4mwpz9sPW; Wed, 20 Nov 2019 16:27:06 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1574227626; bh=pKpuafZcDqiFdJFkncIRk5Np4sv1bwXlnHVfgKCTcvM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MQzQ9yVMvevv8eayeamRF87pavqd59ueZc9PZScnOdOl1fquhKFXLSRhpgyU6BAgG EIkjugAhyYMmqqmrbMt8TaA+qC+4In2xAAcfkw3UfMpIEB1BgZuZWOjYNfNhencuKB cqOTxub3ysbmKSgGXX5uYOWz29tsytjjom7t6MTc= Date: Wed, 20 Nov 2019 16:27:01 +1100 From: David Gibson To: Peter Maydell Subject: Re: [PATCH] exynos4210_gic: Suppress gcc9 format-truncation warnings Message-ID: <20191120052701.GJ5582@umbus.fritz.box> References: <20191004025509.3012-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="UEbtx6mvDyyRl/If" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 X-BeenThere: qemu-arm@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 , qemu-arm , QEMU Developers Errors-To: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: "Qemu-arm" X-TUID: 9cWPQgYa84Mu --UEbtx6mvDyyRl/If Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Oct 14, 2019 at 01:51:39PM +0100, Peter Maydell wrote: > On Fri, 4 Oct 2019 at 04:10, David Gibson w= rote: > > > > exynos4210_gic_realize() prints the number of cpus into some temporary > > buffers, but it only allows 3 bytes space for it. That's plenty - I'm > > pretty sure that existing machines will only ever set this value to 2 > > (EXYNOS4210_NCPUS). But the compiler can't really be expected to figure > > that out. > > > > Some[*] gcc9 versions therefore emit -Wformat-truncation warnings. Fix > > that by allowing more space in the temporary buffers - these are on sta= ck > > very briefly before being essentially strdup()ed inside the memory regi= on > > code, so there's not much cost to doing so. > > > > [*] 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 h= ost > > - Fedora 30 with and gcc-9.2.1-1.fc30.x86_64. > > > > Signed-off-by: David Gibson > > --- > > hw/intc/exynos4210_gic.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c > > index a1b699b6ba..2e5e47f9ec 100644 > > --- a/hw/intc/exynos4210_gic.c > > +++ b/hw/intc/exynos4210_gic.c > > @@ -290,8 +290,8 @@ static void exynos4210_gic_realize(DeviceState *dev= , Error **errp) > > SysBusDevice *sbd =3D SYS_BUS_DEVICE(obj); > > const char cpu_prefix[] =3D "exynos4210-gic-alias_cpu"; > > const char dist_prefix[] =3D "exynos4210-gic-alias_dist"; > > - char cpu_alias_name[sizeof(cpu_prefix) + 3]; > > - char dist_alias_name[sizeof(cpu_prefix) + 3]; > > + char cpu_alias_name[sizeof(cpu_prefix) + 10]; > > + char dist_alias_name[sizeof(cpu_prefix) + 10]; > > SysBusDevice *gicbusdev; > > uint32_t i; >=20 > If we assert() that num_cpu is always <=3D EXYNOS4210_NCPUS > is that sufficient to clue gcc in that the buffer can't overflow? Interestingly, assert(s->num_cpu <=3D EXYNOS$210_NCPUS) is *not* sufficient, but assert(i <=3D EXYNOS4210_NCPUS) within the loop *is* enough. I've updated my patch accordingly. This isn't 4.2 material, obviously. Should I just sit on it until 5.0 opens, or does one of you have someplace to stage the patch in the meanwhile? --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --UEbtx6mvDyyRl/If Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAl3UzqQACgkQbDjKyiDZ s5ICvxAA0Q4kBa2vsJ00sIsTT4gXu3ddnLjtIJ3t+ZvYqJ77jkTa4E8LwT/+JMeZ HAtuexE1eECRj9V1cnhW+/xfGEV83YDgekjFSZzcm1LYCWKGlcFHPefnWCYpFH4L vVsZ8SfU5rN8zdFe5PogFaps7ZuRf3yP8ukc+i3VkRnpTPdterR3xUCQvYoZg7pP 99NCIjD4BFxgcPEmlIGe9LRP0TR72yOO841x1HVRqPFBFr/Ac0440WT2AWSy/Umb utvhUhND9NUyB2g0cACmoT504bbyH0fZOFFB+EdCxTYsgLrjAgEbaV8b7bzefPR5 /2UOber7FCQqowgPyx11uf5djMRc5UKIaZfOkADY1tb1TuCEw7jZq7qsiYNgATXX /5JCRgyC2zMMOwvz4KZaIiR+FooJDCUsZvqEVO5pRtzISY5E/F0tlLDugfHTC8jr q90FrJXr+SvbWCfQXxOGWRMwVN7p2ZI+9dYtwUigPLTdqliSWghg0VhsOf4ZH6xy CGO97V1P4l5OOO3qq4vkilsSaHyEtm04MLZphH0TrVAvZVlt6XbErsSUPQTzpwuU V/I5Lh3ttOtuU9HX4rv6oygJ8pdBn4fs7xRxzSnHau5ZER6/wvk76FD6WKeZP+XP PB8YOavsTZ0OsIhzV/92mxMEsKe/zD9YWgTe22F18n3cpllcyJA= =+Pqu -----END PGP SIGNATURE----- --UEbtx6mvDyyRl/If--