[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 3/5] arm/allwinner-a10: fix format-overflow warning
From: |
Peter Maydell |
Subject: |
Re: [PATCH 3/5] arm/allwinner-a10: fix format-overflow warning |
Date: |
Mon, 28 Mar 2022 09:13:32 +0000 |
On Mon, 28 Mar 2022 at 09:48, <marcandre.lureau@redhat.com> wrote:
>
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> ../hw/arm/allwinner-a10.c: In function ‘aw_a10_realize’:
> ../hw/arm/allwinner-a10.c:135:35: error: ‘%d’ directive writing between 1 and
> 11 bytes into a region of size 8 [-Werror=format-overflow=]
> 135 | sprintf(bus, "usb-bus.%d", i);
> | ^~
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> hw/arm/allwinner-a10.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
> index 05e84728cb34..79082289ea5b 100644
> --- a/hw/arm/allwinner-a10.c
> +++ b/hw/arm/allwinner-a10.c
> @@ -130,9 +130,7 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)
> int i;
>
> for (i = 0; i < AW_A10_NUM_USB; i++) {
> - char bus[16];
> -
> - sprintf(bus, "usb-bus.%d", i);
> + g_autofree char *bus = g_strdup_printf("usb-bus.%d", i);
>
> object_property_set_bool(OBJECT(&s->ehci[i]), "companion-enable",
> true, &error_fatal);
Another false positive. Maybe we should feed this back to the
compiler devs for them to improve their warning generation?
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM