qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 4/5] intc/exynos4210_gic: fix format-overflow warning


From: Peter Maydell
Subject: Re: [PATCH 4/5] intc/exynos4210_gic: fix format-overflow warning
Date: Mon, 28 Mar 2022 09:15:33 +0000

On Mon, 28 Mar 2022 at 09:48, <marcandre.lureau@redhat.com> wrote:
>
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  hw/intc/exynos4210_gic.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c
> index bc73d1f11524..5b6f4330a5f3 100644
> --- a/hw/intc/exynos4210_gic.c
> +++ b/hw/intc/exynos4210_gic.c
> @@ -289,10 +289,6 @@ static void exynos4210_gic_realize(DeviceState *dev, 
> Error **errp)
>      Object *obj = OBJECT(dev);
>      Exynos4210GicState *s = EXYNOS4210_GIC(obj);
>      SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
> -    const char cpu_prefix[] = "exynos4210-gic-alias_cpu";
> -    const char dist_prefix[] = "exynos4210-gic-alias_dist";
> -    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;
> @@ -322,8 +318,10 @@ static void exynos4210_gic_realize(DeviceState *dev, 
> Error **errp)
>       */
>      assert(n <= EXYNOS4210_NCPUS);
>      for (i = 0; i < n; i++) {
> +        g_autofree char *cpu_alias_name = 
> g_strdup_printf("exynos4210-gic-alias_cpu%x", i);
> +        g_autofree char *dist_alias_name = 
> g_strdup_printf("exynos4210-gic-alias_dist%x", 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,
>                                   cpu_alias_name,
>                                   sysbus_mmio_get_region(gicbusdev, 1),
> @@ -333,7 +331,6 @@ static void exynos4210_gic_realize(DeviceState *dev, 
> Error **errp)
>                  EXYNOS4210_EXT_GIC_CPU_GET_OFFSET(i), &s->cpu_alias[i]);
>
>          /* Map Distributor per SMP Core */
> -        sprintf(dist_alias_name, "%s%x", dist_prefix, i);
>          memory_region_init_alias(&s->dist_alias[i], obj,
>                                   dist_alias_name,
>                                   sysbus_mmio_get_region(gicbusdev, 0),
> --

More false positives, but here the new code is massively better than the old.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]