From patchwork Mon Dec 16 11:08:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 181680 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp4173104ile; Mon, 16 Dec 2019 03:22:19 -0800 (PST) X-Google-Smtp-Source: APXvYqz044O5ZHNqmU6CP4teyZ19dh/qFjmjGfLxcVYF2FVSWIMC4BfDTSSFwUXA/EAiwSs+EMdR X-Received: by 2002:ae9:ee0f:: with SMTP id i15mr25353109qkg.16.1576495339208; Mon, 16 Dec 2019 03:22:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576495339; cv=none; d=google.com; s=arc-20160816; b=cdC8kfyYUL91+EcwnRNBIPYA2jNtpN7fvyXWJmDETlYmeJS2hsDXton0naX2bUkUCc +V0EVA4R/AyKQSqT7/V9hDaGyWF8NheiRCCYC0HmBHa2my0rYhxbY1UtJlsR9dS5+++0 x5b0btK4Aa0pb9dn3vJUYsLmA54w+p0htajLKQSfjQ00oBTTuDzvGIcRQlsjMLOdmJqV s+jpXS+/uo/xzSMAdZ0sIarRtTulOY0kov6kHC8FM1IVjimiboElxmHEsfG747G30KiO ImKoKfpMA7Gr39xVxwgq+OkS5nQDnWvbFwB4vv8vtSXlBsJN3DZxTuQWua50CfsPipDD jXow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=0cxUjenX4Zcy7AbEng8uMiqxruOg2URtl6WiQlwztWY=; b=lfSSDXCg5zCOzqehX+gbXuNHsEK4DTnFOa2rZ6bULjC5FHq0NWi617WRXNmHH4GamK X2tumPlOkOD+h46WixWk29Xh6XgZdkrlR/pfu3aTE7hr0aUpTNWlHuTU3xJbtjGQNff7 2Ggzybz0Jdw7xlis0s9fN1myhWzVbLStkYxLe7srUc7H5JyN/aL+s98E/dv++R+lJSnI 2HeIdiPjQC+U031hsigBSmm/auONlsKFCDH0T6sTBrMQbzdpM0QObtFIqD6LnfRckQdj P3Vuz40ed2V3RPTDoayVA/p9BZI5KbUMBtocft6bua+biovXVKqD3AUs2uJ5kIJh6sIk M/CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OoxFesnG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f2si2554712qvr.61.2019.12.16.03.22.19 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Dec 2019 03:22:19 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=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=@linaro.org header.s=google header.b=OoxFesnG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1igoS9-0006OQ-0k for patch@linaro.org; Mon, 16 Dec 2019 06:22:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50765) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1igoFX-0007TA-B6 for qemu-devel@nongnu.org; Mon, 16 Dec 2019 06:09:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1igoFW-0007b4-6z for qemu-devel@nongnu.org; Mon, 16 Dec 2019 06:09:15 -0500 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:39898) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1igoFW-0007YI-0v for qemu-devel@nongnu.org; Mon, 16 Dec 2019 06:09:14 -0500 Received: by mail-wr1-x442.google.com with SMTP id y11so6713523wrt.6 for ; Mon, 16 Dec 2019 03:09:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=0cxUjenX4Zcy7AbEng8uMiqxruOg2URtl6WiQlwztWY=; b=OoxFesnGk7aZGqX+4z+XcMIf2Zw6/yhJbnwffVqohS6sknLVmcjQa1qnyCk5tly0T8 oKJ2AbXA1xbA3sA8iOH2LF1aiRlY/KjmFblEyPf8gCD62BOfkirRwtrBp9VzfudrWHh6 2VowCLgf7xAFZNmrl8Zx+gGvWmJKRbeQILpGkBeqClAc4v2Hj+70XT5Y9Gd8LAaihqye BGAZC/FgLoO8uYRVOzaIy+sPCIKsmWgvzZBWfU8M5/i7WMeM1j9N98/Ulr3fdhSMkSDP eze2BK3wMnYpsYrtN1sC4KFPUCuZ4NS3EcfJj//IEn3kxIo44vYs0beGknqBMyKXxG3V EYrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0cxUjenX4Zcy7AbEng8uMiqxruOg2URtl6WiQlwztWY=; b=qIb8lN+W865esFVA8gyzG+zV2hk9MhTWuIAwJbAJiHbLaKpLjDCkcqv8Qse3XEBNm6 2T296U9aBtjG+eKSAMcckx1ixiLOz2uR7VvjJTW76CDHdEJI+Vg+bEsiEMJ7zWpkZ1n8 j63IRlSh1bCFtow7DgMAdSBfyN1AqUnnZZjeH1dfEGYadnLPsbQPux0kLzpD1pVyZyDt U5nkrNTt1O79lJvINGaCpjBdAHWCb3+QLfbwOAEfPr+bJSPHUb1cPzjn+oE01Xra4D7a qrlHnMz7uBbyUrU8r1vsxCsjeuvTllMSof5Q3HAzXZ64ahz5puHKXguH/ldfe4/pDRep jtWg== X-Gm-Message-State: APjAAAWyHYwAIw3o8D6ySDo39zLr3fubPyXTmPGBaV88ep1x/9Ke6yMO ELCNsEFdsjmZrLqHoWeSNmHMPYeMs71Ajw== X-Received: by 2002:a5d:6ac3:: with SMTP id u3mr30537669wrw.25.1576494549841; Mon, 16 Dec 2019 03:09:09 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id x10sm20976131wrp.58.2019.12.16.03.09.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2019 03:09:09 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 02/34] exynos4210_gic: Suppress gcc9 format-truncation warnings Date: Mon, 16 Dec 2019 11:08:32 +0000 Message-Id: <20191216110904.30815-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191216110904.30815-1-peter.maydell@linaro.org> References: <20191216110904.30815-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: David Gibson 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é Reviewed-by: Richard Henderson [PMM: deleted stray blank line] Signed-off-by: Peter Maydell --- hw/intc/exynos4210_gic.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c index a1b699b6bab..9a84d8522e9 100644 --- a/hw/intc/exynos4210_gic.c +++ b/hw/intc/exynos4210_gic.c @@ -293,6 +293,7 @@ static void exynos4210_gic_realize(DeviceState *dev, Error **errp) char cpu_alias_name[sizeof(cpu_prefix) + 3]; char dist_alias_name[sizeof(cpu_prefix) + 3]; SysBusDevice *gicbusdev; + uint32_t n = s->num_cpu; uint32_t i; s->gic = qdev_create(NULL, "arm_gic"); @@ -313,7 +314,13 @@ static void exynos4210_gic_realize(DeviceState *dev, Error **errp) memory_region_init(&s->dist_container, obj, "exynos4210-dist-container", EXYNOS4210_EXT_GIC_DIST_REGION_SIZE); - for (i = 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 <= EXYNOS4210_NCPUS); + for (i = 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,