Skip to content
Snippets Groups Projects
Commit e5c41835 authored by Marc-André Lureau's avatar Marc-André Lureau
Browse files

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: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: default avatarPeter Maydell <peter.maydell@linaro.org>
Reviewed-by: default avatarDaniel P. Berrangé <berrange@redhat.com>
Message-Id: <20220420132624.2439741-14-marcandre.lureau@redhat.com>
parent 7a42e688
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment