[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] tests/unit: fix a -Wformat-trunction warning
From: |
Peter Maydell |
Subject: |
Re: [PATCH] tests/unit: fix a -Wformat-trunction warning |
Date: |
Fri, 12 Aug 2022 11:23:55 +0100 |
On Wed, 10 Aug 2022 at 13:20, <marcandre.lureau@redhat.com> wrote:
>
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> ../tests/test-qobject-input-visitor.c: In function ‘test_visitor_in_list’:
> ../tests/test-qobject-input-visitor.c:454:49: warning: ‘%d’ directive output
> may be truncated writing between 1 and 10 bytes into a region of size 6
> [-Wformat-truncation=]
> 454 | snprintf(string, sizeof(string), "string%d", i);
> | ^~
> ../tests/test-qobject-input-visitor.c:454:42: note: directive argument in the
> range [0, 2147483606]
> 454 | snprintf(string, sizeof(string), "string%d", i);
> | ^~~~~~~~~~
> ../tests/test-qobject-input-visitor.c:454:9: note: ‘snprintf’ output between
> 8 and 17 bytes into a destination of size 12
> 454 | snprintf(string, sizeof(string), "string%d", i);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Not trying to be clever, this is called 3 times during tests,
> let simply use g_strdup_printf().
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This is a pretty safe fix and compiler warnings seem like they're
worth fixing for rc3. Since I need to do a target-arm pullreq
anyway I'll take this via that, unless anybody objects.
(I've fixed up the commit message typo in my tree.)
thanks
-- PMM