Message ID | 20191202060806.77968-1-david@gibson.dropbear.id.au |
---|---|
State | New |
Headers | show |
Series | [PATCHv3] exynos4210_gic: Suppress gcc9 format-truncation warnings | expand |
On 12/1/19 6:08 AM, David Gibson wrote: > > - 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 */ Watch out for the extra line added at the start of the block. Otherwise, Reviewed-by: Richard Henderson <richard.henderson@linaro.org> r~
On Mon, 2 Dec 2019 at 16:08, Richard Henderson <richard.henderson@linaro.org> wrote: > > On 12/1/19 6:08 AM, David Gibson wrote: > > > > - 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 */ > > Watch out for the extra line added at the start of the block. Otherwise, > > Reviewed-by: Richard Henderson <richard.henderson@linaro.org> I thought about putting this in rc4 but eventually decided against it. Queued for 5.0 (with the stray extra blank line removed). thanks -- PMM
On Mon, Dec 02, 2019 at 05:44:11PM +0000, Peter Maydell wrote: > On Mon, 2 Dec 2019 at 16:08, Richard Henderson > <richard.henderson@linaro.org> wrote: > > > > On 12/1/19 6:08 AM, David Gibson wrote: > > > > > > - 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 */ > > > > Watch out for the extra line added at the start of the block. Otherwise, > > > > Reviewed-by: Richard Henderson <richard.henderson@linaro.org> > > I thought about putting this in rc4 but eventually decided > against it. Queued for 5.0 (with the stray extra blank line > removed). Great!
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, 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,14 @@ 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,