aboutsummaryrefslogtreecommitdiff
path: root/hw/arm/digic.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2022-04-20 17:25:56 +0400
committerMarc-André Lureau <marcandre.lureau@redhat.com>2022-04-21 17:03:51 +0400
commite5c41835250ebb3f0297606bc7cc48cfa5474e8f (patch)
treef9a0d81e6bebe1afe1de2f4fde1a7c4826d59311 /hw/arm/digic.c
parent7a42e6885aab340c1fad8efea95929b673714ecc (diff)
arm/digic: replace snprintf() with g_strdup_printf()
Also fixes a GCC 12.0.1 false-positive: ../hw/arm/digic.c: In function ‘digic_init’: ../hw/arm/digic.c:45:54: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 5 [-Werror=format-truncation=] 45 | snprintf(name, DIGIC_TIMER_NAME_MLEN, "timer[%d]", i); | ^~ Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20220420132624.2439741-14-marcandre.lureau@redhat.com>
Diffstat (limited to 'hw/arm/digic.c')
-rw-r--r--hw/arm/digic.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/hw/arm/digic.c b/hw/arm/digic.c
index 614232165c..6df5547977 100644
--- a/hw/arm/digic.c
+++ b/hw/arm/digic.c
@@ -39,10 +39,7 @@ static void digic_init(Object *obj)
object_initialize_child(obj, "cpu", &s->cpu, ARM_CPU_TYPE_NAME("arm946"));
for (i = 0; i < DIGIC4_NB_TIMERS; i++) {
-#define DIGIC_TIMER_NAME_MLEN 11
- char name[DIGIC_TIMER_NAME_MLEN];
-
- snprintf(name, DIGIC_TIMER_NAME_MLEN, "timer[%d]", i);
+ g_autofree char *name = g_strdup_printf("timer[%d]", i);
object_initialize_child(obj, name, &s->timer[i], TYPE_DIGIC_TIMER);
}