[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 02/34] exynos4210_gic: Suppress gcc9 format-truncation warnings
From: |
Peter Maydell |
Subject: |
[PULL 02/34] exynos4210_gic: Suppress gcc9 format-truncation warnings |
Date: |
Mon, 16 Dec 2019 11:08:32 +0000 |
From: David Gibson <address@hidden>
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 <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
[PMM: deleted stray blank line]
Signed-off-by: Peter Maydell <address@hidden>
---
hw/intc/exynos4210_gic.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
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,
--
2.20.1
- [PULL 00/34] target-arm queue, Peter Maydell, 2019/12/16
- [PULL 01/34] target/arm: Add support for cortex-m7 CPU, Peter Maydell, 2019/12/16
- [PULL 05/34] aspeed: Add a DRAM memory region at the SoC level, Peter Maydell, 2019/12/16
- [PULL 02/34] exynos4210_gic: Suppress gcc9 format-truncation warnings,
Peter Maydell <=
- [PULL 04/34] aspeed/i2c: Check SRAM enablement on AST2500, Peter Maydell, 2019/12/16
- [PULL 03/34] aspeed/i2c: Add support for pool buffer transfers, Peter Maydell, 2019/12/16
- [PULL 06/34] aspeed/i2c: Add support for DMA transfers, Peter Maydell, 2019/12/16
- [PULL 08/34] aspeed/sdmc: Make ast2600 default 1G, Peter Maydell, 2019/12/16
- [PULL 09/34] aspeed/scu: Fix W1C behavior, Peter Maydell, 2019/12/16
- [PULL 07/34] aspeed/i2c: Add trace events, Peter Maydell, 2019/12/16
- [PULL 12/34] aspeed/smc: Restore default AHB window mapping at reset, Peter Maydell, 2019/12/16
- [PULL 10/34] watchdog/aspeed: Improve watchdog timeout message, Peter Maydell, 2019/12/16
- [PULL 11/34] watchdog/aspeed: Fix AST2600 frequency behaviour, Peter Maydell, 2019/12/16
- [PULL 13/34] aspeed/smc: Do not map disabled segment on the AST2600, Peter Maydell, 2019/12/16