Compilation fixes for 7.0
cover Compilation fixes for 7.0
From: Marc-André Lureau <[email protected]>
Hi,
UST tracing fails to build on Fedora 36, with lttng-ust-2.13.1-2.fc36.x86_64.
There are also various GCC 12.0.1 warnings worth fixing.
Marc-André Lureau (5):
trace: fix compilation with lttng-ust >= 2.13 arm/digic: fix format-truncation warning arm/allwinner-a10: fix format-overflow warning intc/exynos4210_gic: fix format-overflow warning s390x/tcg: fix format-truncation warning
meson.build | 4 ++-- hw/arm/allwinner-a10.c | 4 +--- hw/arm/digic.c | 5 +---- hw/intc/exynos4210_gic.c | 9 +++------ target/s390x/tcg/translate.c | 4 ++-- scripts/tracetool/format/ust_events_h.py | 4 ++-- 6 files changed, 11 insertions(+), 19 deletions(-)
Signature · 1 line
2.35.1.273.ge6ebfd0e8cbb
PATCH 1/5 trace: fix compilation with lttng-ust >= 2.13
From: Marc-André Lureau <[email protected]>
On Fedora 36, with lttng-ust 2.13.1, compilation fails with:
In file included from trace/trace-ust-all.h:49085,
from trace/trace-ust-all.c:13:
/usr/include/lttng/tracepoint-event.h:67:10: error: #include expects "FILENAME" or <FILENAME>
67 | #include LTTNG_UST_TRACEPOINT_INCLUDE
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~In lttng-ust commit 41858e2b6e8 ("Fix: don't do macro expansion in tracepoint file name") from 2012, starting from lttng-ust 2.1, the API was changed to expect TRACEPOINT_INCLUDE to be defined as a string.
In lttng-ust commit d2966b4b0b2 ("Remove TRACEPOINT_INCLUDE_FILE macro"), in 2021, the compatibility macro was removed.
Use the "new" API from 2012, and bump the version requirement to 2.1 to fix compilation with >= 2.13.
According to repology, all distributions we support have >= 2.1 (centos 8 has oldest with 2.8.1 afaict)
--- meson.build | 4 ++-- scripts/tracetool/format/ust_events_h.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
meson.build +2 -2
@@ -455,8 +455,8 @@ if 'CONFIG_GIO' in config_host endif lttng = not_found if 'ust' in get_option('trace_backends') - lttng = dependency('lttng-ust', required: true, method: 'pkg-config', - kwargs: static_kwargs) + lttng = dependency('lttng-ust', required: true, version: '>= 2.1', + method: 'pkg-config', kwargs: static_kwargs) endif pixman = not_found if have_system or have_tools
scripts/tracetool/format/ust_events_h.py +2 -2
@@ -29,8 +29,8 @@ def generate(events, backend, group): '#undef TRACEPOINT_PROVIDER', '#define TRACEPOINT_PROVIDER qemu', '', - '#undef TRACEPOINT_INCLUDE_FILE', - '#define TRACEPOINT_INCLUDE_FILE ./%s' % include, + '#undef TRACEPOINT_INCLUDE', + '#define TRACEPOINT_INCLUDE "./%s"' % include, '', '#if !defined (TRACE_%s_GENERATED_UST_H) || \\' % group.upper(), ' defined(TRACEPOINT_HEADER_MULTI_READ)',
Signature · 1 line
2.35.1.273.ge6ebfd0e8cbb
Re: [PATCH 1/5] trace: fix compilation with lttng-ust >= 2.13
Quoted 20 lines · On Mon, Mar 28, 2022 at 12:47:13PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
On Fedora 36, with lttng-ust 2.13.1, compilation fails with:
In file included from
trace/trace-ust-all.h:49085,from trace/trace-ust-all.c:13: /usr/include/lttng/tracepoint-event.h:67:10: error: #include expects "FILENAME" or <FILENAME> 67 | #include LTTNG_UST_TRACEPOINT_INCLUDE | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~In lttng-ust commit
41858e2b6e8("Fix: don't do macro expansion in tracepoint file name") from 2012, starting from lttng-ust 2.1, the API was changed to expectTRACEPOINT_INCLUDEto be defined as a string.In lttng-ust commit
d2966b4b0b2("RemoveTRACEPOINT_INCLUDE_FILEmacro"), in 2021, the compatibility macro was removed.Use the "new" API from 2012, and bump the version requirement to 2.1 to fix compilation with >= 2.13.
Quoted 8 lines
According to repology, all distributions we support have >= 2.1 (centos 8 has oldest with 2.8.1 afaict)
Signed-off-by Marc-André Lureau <[email protected]>--- meson.build | 4 ++-- scripts/tracetool/format/ust_events_h.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
Thank you!
Re: [PATCH 1/5] trace: fix compilation with lttng-ust >= 2.13
Hi
Quoted 31 lines · Stefan Hajnoczi
Quoted 20 lines · On Mon, Mar 28, 2022 at 12:47:13PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
On Fedora 36, with lttng-ust 2.13.1, compilation fails with:
In file included from
trace/trace-ust-all.h:49085,from trace/trace-ust-all.c:13: /usr/include/lttng/tracepoint-event.h:67:10: error: #include expects "FILENAME" or <FILENAME> 67 | #include LTTNG_UST_TRACEPOINT_INCLUDE | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~In lttng-ust commit
41858e2b6e8("Fix: don't do macro expansion in tracepoint file name") from 2012, starting from lttng-ust 2.1, the API was changed to expectTRACEPOINT_INCLUDEto be defined as a string.In lttng-ust commit
d2966b4b0b2("RemoveTRACEPOINT_INCLUDE_FILEmacro"), in 2021, the compatibility macro was removed.Use the "new" API from 2012, and bump the version requirement to 2.1 to fix compilation with >= 2.13.
Quoted 8 lines
According to repology, all distributions we support have >= 2.1 (centos 8 has oldest with 2.8.1 afaict)
Signed-off-by Marc-André Lureau <[email protected]>--- meson.build | 4 ++-- scripts/tracetool/format/ust_events_h.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
Quoted 3 lines
Thank you!
Reviewed-by Stefan Hajnoczi <[email protected]>
Given that there is a dependency bump, would you rather wait for 7.1 or do you think it should be included in 7.0? I think the latter should be safe.
thanks
Re: [PATCH 1/5] trace: fix compilation with lttng-ust >= 2.13
Quoted 34 lines · Marc-André Lureau
Hi
Quoted 31 lines · Stefan Hajnoczi
Quoted 28 lines · On Mon, Mar 28, 2022 at 12:47:13PM +0400, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
On Fedora 36, with lttng-ust 2.13.1, compilation fails with:
In file included from
trace/trace-ust-all.h:49085,from trace/trace-ust-all.c:13: /usr/include/lttng/tracepoint-event.h:67:10: error: #include expects "FILENAME" or <FILENAME> 67 | #include LTTNG_UST_TRACEPOINT_INCLUDE | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~In lttng-ust commit
41858e2b6e8("Fix: don't do macro expansion in tracepoint file name") from 2012, starting from lttng-ust 2.1, the API was changed to expectTRACEPOINT_INCLUDEto be defined as a string.In lttng-ust commit
d2966b4b0b2("RemoveTRACEPOINT_INCLUDE_FILEmacro"), in 2021, the compatibility macro was removed.Use the "new" API from 2012, and bump the version requirement to 2.1 to fix compilation with >= 2.13.
According to repology, all distributions we support have >= 2.1 (centos 8 has oldest with 2.8.1 afaict)
Signed-off-by Marc-André Lureau <[email protected]>--- meson.build | 4 ++-- scripts/tracetool/format/ust_events_h.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
Quoted 7 lines
Quoted 3 lines
Thank you!
Reviewed-by Stefan Hajnoczi <[email protected]>Given that there is a dependency bump, would you rather wait for 7.1 or do you think it should be included in 7.0? I think the latter should be safe.
Yes, since you've investigated the minimum version available across supported distros I think we can apply this patch.
Thanks,
Stefan
PATCH 2/5 arm/digic: fix format-truncation warning
In reply to [email protected]From: Marc-André Lureau <[email protected]>
../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);
| ^~
--- hw/arm/digic.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
hw/arm/digic.c +1 -4
@@ -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 ); }
Signature · 1 line
2.35.1.273.ge6ebfd0e8cbb
Re: [PATCH 2/5] arm/digic: fix format-truncation warning
Quoted 18 lines · On Mon, 28 Mar 2022 at 09:47, <[email protected]> wrote:
From: Marc-André Lureau <[email protected]>
../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 <[email protected]>--- hw/arm/digic.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)hw/arm/digic.c +0
-0
hw/arm/digic.c static void digic_init(Object *obj) · line 44
Quoted 10 lines
hw/arm/digic.c +1
-4@@ -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 ); }
This is a clear compiler false positive, given that DIGIC4_NB_TIMERS is 3. But this is a nicer way to write the code than the static array anyway.
thanks
-- PMM
Re: [PATCH 2/5] arm/digic: fix format-truncation warning
In reply to [email protected]Quoted 18 lines · On 28/03/2022 10.47, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
../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 <[email protected]>--- hw/arm/digic.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)hw/arm/digic.c +0
-0@@ -39,10 +39,7 @@ static void digic_init(Object *obj)object_initialize_child (obj,"cpu" , &s->cpu,ARM_CPU_TYPE_NAME ("arm946" ));
hw/arm/digic.c static void digic_init(Object *obj) · line 45
Quoted 10 lines
hw/arm/digic.c +1
-4for (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 ); }
DIGIC4_NB_TIMERS is 3 ... so the compiler should also be able to see that the string fits fine into the name[] array here. That really sounds like your GCC 12.0 is buggy. Please open a compiler bug ticket.
Thomas
PATCH 3/5 arm/allwinner-a10: fix format-overflow warning
In reply to [email protected]From: Marc-André Lureau <[email protected]>
../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);
| ^~
--- hw/arm/allwinner-a10.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
hw/arm/allwinner-a10.c +1 -3
@@ -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);
Signature · 1 line
2.35.1.273.ge6ebfd0e8cbb
Re: [PATCH 3/5] arm/allwinner-a10: fix format-overflow warning
Quoted 18 lines · On Mon, 28 Mar 2022 at 09:48, <[email protected]> wrote:
From: Marc-André Lureau <[email protected]>
../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 <[email protected]>--- hw/arm/allwinner-a10.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)hw/arm/allwinner-a10.c +0
-0
hw/arm/allwinner-a10.c static void aw_a10_realize(DeviceState *dev, Error **errp) · line 136
Quoted 10 lines
hw/arm/allwinner-a10.c +1
-3@@ -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?
thanks
-- PMM
PATCH 4/5 intc/exynos4210_gic: fix format-overflow warning
In reply to [email protected]From: Marc-André Lureau <[email protected]>
--- hw/intc/exynos4210_gic.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
hw/intc/exynos4210_gic.c +3 -6
@@ -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),
Signature · 1 line
2.35.1.273.ge6ebfd0e8cbb
Re: [PATCH 4/5] intc/exynos4210_gic: fix format-overflow warning
Quoted 36 lines · On Mon, 28 Mar 2022 at 09:48, <[email protected]> wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>--- hw/intc/exynos4210_gic.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)hw/intc/exynos4210_gic.c +3
-5@@ -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),
hw/intc/exynos4210_gic.c static void exynos4210_gic_realize(DeviceState *dev, Error **errp)
Quoted 8 lines
hw/intc/exynos4210_gic.c +0
-2@@ -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.
thanks
-- PMM
Re: [PATCH 4/5] intc/exynos4210_gic: fix format-overflow warning
Quoted 22 lines · Peter Maydell
Quoted 21 lines · On Mon, 28 Mar 2022 at 09:48, <[email protected]> wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>--- hw/intc/exynos4210_gic.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)hw/intc/exynos4210_gic.c +0
-4@@ -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;
Quoted 8 lines
hw/intc/exynos4210_gic.c static void exynos4210_gic_realize(DeviceState *dev, Error **errp) · line 322
Quoted 8 lines
hw/intc/exynos4210_gic.c +2
-0uint32_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);
Dubious '%x' format... Maybe change to '%u'?
Quoted 21 lines
Quoted 6 lines
hw/intc/exynos4210_gic.c +0
-1/* 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),hw/intc/exynos4210_gic.c static void exynos4210_gic_realize(DeviceState *dev, Error **errp)
Quoted 8 lines
hw/intc/exynos4210_gic.c +0
-2@@ -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 <[email protected]>thanks
-- PMM
Re: [PATCH 4/5] intc/exynos4210_gic: fix format-overflow warning
Quoted 26 lines · Philippe Mathieu-Daudé
Quoted 24 lines · Peter Maydell
Quoted 23 lines · On Mon, 28 Mar 2022 at 09:48, <[email protected]> wrote:
From: Marc-André Lureau <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>--- hw/intc/exynos4210_gic.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)hw/intc/exynos4210_gic.c +0
-4@@ -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;
Quoted 8 lines
Quoted 6 lines
hw/intc/exynos4210_gic.c static void exynos4210_gic_realize(DeviceState *dev, Error **errp) · line 322
Quoted 6 lines
hw/intc/exynos4210_gic.c +2
-0@@ -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);Dubious '%x' format... Maybe change to '%u'?
Makes no difference given that EXYNOS4210_NCPUS is 2, but I guess so.
-- PMM
PATCH 5/5 s390x/tcg: fix format-truncation warning
In reply to [email protected]From: Marc-André Lureau <[email protected]>
../target/s390x/tcg/translate.c: In function ‘s390x_translate_init’:../target/s390x/tcg/translate.c:224:64: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 3 [-Werror=format-truncation=]
224 | snprintf(cpu_reg_names[i], sizeof(cpu_reg_names[0]), "r%d", i);
| ^~
--- target/s390x/tcg/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target/s390x/tcg/translate.c +2 -2
@@ -199,7 +199,7 @@ static TCGv_i64 regs[16];void s390x_translate_init (void ) { -int i; +size_t i; psw_addr =tcg_global_mem_new_i64 (cpu_env, offsetof(CPUS390XState, psw.addr),
@@ -221,7 +221,7 @@ void s390x_translate_init(void) "cc_vr");for (i =0 ; i <16 ; i++) { -snprintf (cpu_reg_names[i],sizeof (cpu_reg_names[0 ]),"r%d" , i); +snprintf (cpu_reg_names[i],sizeof (cpu_reg_names[0 ]),"r%zu" , i); regs[i] =tcg_global_mem_new (cpu_env, offsetof(CPUS390XState, regs[i]), cpu_reg_names[i]);
Signature · 1 line
2.35.1.273.ge6ebfd0e8cbb
Re: [PATCH 5/5] s390x/tcg: fix format-truncation warning
Quoted 26 lines · On 28/03/2022 10.47, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
../target/s390x/tcg/translate.c: In function ‘s390x_translate_init’:../target/s390x/tcg/translate.c:224:64: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 3 [-Werror=format-truncation=]
224 |snprintf(cpu_reg_names[i], sizeof(cpu_reg_names[0]), "r%d", i);
| ^~Signed-off-by Marc-André Lureau <[email protected]>--- target/s390x/tcg/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)target/s390x/tcg/translate.c +1
-1@@ -199,7 +199,7 @@ static TCGv_i64 regs[16];void s390x_translate_init (void ) { -int i; +size_t i; psw_addr =tcg_global_mem_new_i64 (cpu_env, offsetof(CPUS390XState, psw.addr),
target/s390x/tcg/translate.c void s390x_translate_init(void) · line 224
Quoted 5 lines
target/s390x/tcg/translate.c +1
-1@@ -221,7 +221,7 @@ void s390x_translate_init(void) "cc_vr");for (i =0 ; i <16 ; i++) { -snprintf (cpu_reg_names[i],sizeof (cpu_reg_names[0 ]),"r%d" , i); +snprintf (cpu_reg_names[i],sizeof (cpu_reg_names[0 ]),"r%zu" , i);
The compiler is *really* too stupid to see that i is in the range between 0 and 16 here??? ... that rather sounds like a compiler bug to me than something that we should work-around in the QEMU source code. Considering that you're using a x.0 release of GCC, please file a bug against GCC instead. If they refuse to fix it for GCC 12.1 or later, we can revisit this patch, but currently, I really think this should be fixed in GCC instead.
Thomas
Re: [PATCH 5/5] s390x/tcg: fix format-truncation warning
Hi
Quoted 30 lines · Thomas Huth
Quoted 28 lines · On 28/03/2022 10.47, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
../target/s390x/tcg/translate.c: In function ‘s390x_translate_init’:../target/s390x/tcg/translate.c:224:64: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 3 [-Werror=format-truncation=]
224 |snprintf(cpu_reg_names[i], sizeof(cpu_reg_names[0]), "r%d", i);
| ^~Signed-off-by Marc-André Lureau <[email protected]>--- target/s390x/tcg/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)target/s390x/tcg/translate.c +1
-1@@ -199,7 +199,7 @@ static TCGv_i64 regs[16];void s390x_translate_init (void ) { -int i; +size_t i; psw_addr =tcg_global_mem_new_i64 (cpu_env, offsetof(CPUS390XState, psw.addr),@@ -221,7 +221,7 @@ void s390x_translate_init(void) "cc_vr");
Quoted 11 lines
target/s390x/tcg/translate.c void s390x_translate_init(void) · line 224
Quoted 3 lines
target/s390x/tcg/translate.c +1
-1for (i =0 ; i <16 ; i++) { -snprintf (cpu_reg_names[i],sizeof (cpu_reg_names[0 ]),"r%d" , i); +snprintf (cpu_reg_names[i],sizeof (cpu_reg_names[0 ]),"r%zu" , i);The compiler is *really* too stupid to see that i is in the range between 0 and 16 here??? ... that rather sounds like a compiler bug to me than something that we should work-around in the QEMU source code. Considering that you're using a x.0 release of GCC, please file a bug against GCC instead. If they refuse to fix it for GCC 12.1 or later, we can revisit this patch, but currently, I really think this should be fixed in GCC instead.
I opened: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105080
Although I think the "workaround" is simple and would avoid users & distributions having to add --disable-werror, and possibly miss other issues.
Re: [PATCH 5/5] s390x/tcg: fix format-truncation warning
Quoted 45 lines · Marc-André Lureau
Hi
Quoted 30 lines · Thomas Huth
Quoted 28 lines · On 28/03/2022 10.47, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
../target/s390x/tcg/translate.c: In function ‘s390x_translate_init’:../target/s390x/tcg/translate.c:224:64: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 3 [-Werror=format-truncation=]224 | snprintf(cpu_reg_names[i], sizeof(cpu_reg_names[0]), "r%d", i); | ^~Signed-off-by Marc-André Lureau <[email protected]>--- target/s390x/tcg/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)target/s390x/tcg/translate.c +1
-1@@ -199,7 +199,7 @@ static TCGv_i64 regs[16];void s390x_translate_init (void ) { -int i; +size_t i; psw_addr =tcg_global_mem_new_i64 (cpu_env, offsetof(CPUS390XState, psw.addr),@@ -221,7 +221,7 @@ void s390x_translate_init(void) "cc_vr");Quoted 11 lines
target/s390x/tcg/translate.c void s390x_translate_init(void) · line 224
Quoted 3 lines
target/s390x/tcg/translate.c +1
-1for (i =0 ; i <16 ; i++) { -snprintf (cpu_reg_names[i],sizeof (cpu_reg_names[0 ]),"r%d" , i); +snprintf (cpu_reg_names[i],sizeof (cpu_reg_names[0 ]),"r%zu" , i);The compiler is *really* too stupid to see that i is in the range between 0 and 16 here??? ... that rather sounds like a compiler bug to me than something that we should work-around in the QEMU source code. Considering that you're using a x.0 release of GCC, please file a bug against GCC instead. If they refuse to fix it for GCC 12.1 or later, we can revisit this patch, but currently, I really think this should be fixed in GCC instead.
Quoted 5 lines
I opened: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105080
Although I think the "workaround" is simple and would avoid users & distributions having to add --disable-werror, and possibly miss other issues.
But I really dislike adding such noise to the history (it spoils "git blame" for example) if it is not really necessary. In this case, it also rather helps to show distros that they are shipping a buggy compiler and they should fix their compiler instead before it hits their users. So I think it would be rather bad to fix this in QEMU now.
Thomas
Re: [PATCH 5/5] s390x/tcg: fix format-truncation warning
In reply to Marc-André LureauQuoted 45 lines · Marc-André Lureau
Hi
Quoted 30 lines · Thomas Huth
Quoted 28 lines · On 28/03/2022 10.47, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
../target/s390x/tcg/translate.c: In function ‘s390x_translate_init’:../target/s390x/tcg/translate.c:224:64: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 3 [-Werror=format-truncation=]224 | snprintf(cpu_reg_names[i], sizeof(cpu_reg_names[0]), "r%d", i); | ^~Signed-off-by Marc-André Lureau <[email protected]>--- target/s390x/tcg/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)target/s390x/tcg/translate.c +1
-1@@ -199,7 +199,7 @@ static TCGv_i64 regs[16];void s390x_translate_init (void ) { -int i; +size_t i; psw_addr =tcg_global_mem_new_i64 (cpu_env, offsetof(CPUS390XState, psw.addr),@@ -221,7 +221,7 @@ void s390x_translate_init(void) "cc_vr");Quoted 11 lines
target/s390x/tcg/translate.c void s390x_translate_init(void) · line 224
Quoted 3 lines
target/s390x/tcg/translate.c +1
-1for (i =0 ; i <16 ; i++) { -snprintf (cpu_reg_names[i],sizeof (cpu_reg_names[0 ]),"r%d" , i); +snprintf (cpu_reg_names[i],sizeof (cpu_reg_names[0 ]),"r%zu" , i);The compiler is *really* too stupid to see that i is in the range between 0 and 16 here??? ... that rather sounds like a compiler bug to me than something that we should work-around in the QEMU source code. Considering that you're using a x.0 release of GCC, please file a bug against GCC instead. If they refuse to fix it for GCC 12.1 or later, we can revisit this patch, but currently, I really think this should be fixed in GCC instead.
Quoted 1 line
I opened: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105080
Thanks! Looks like it will be fixed in the final release of GCC 12, so I think we can definitely drop this QEMU patch here.
Thomas
Re: [PATCH 5/5] s390x/tcg: fix format-truncation warning
In reply to [email protected]Quoted 26 lines · On 28.03.22 10:47, [email protected] wrote:
From: Marc-André Lureau <[email protected]>
../target/s390x/tcg/translate.c: In function ‘s390x_translate_init’:../target/s390x/tcg/translate.c:224:64: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 3 [-Werror=format-truncation=]
224 |snprintf(cpu_reg_names[i], sizeof(cpu_reg_names[0]), "r%d", i);
| ^~Signed-off-by Marc-André Lureau <[email protected]>--- target/s390x/tcg/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)target/s390x/tcg/translate.c +1
-1@@ -199,7 +199,7 @@ static TCGv_i64 regs[16];void s390x_translate_init (void ) { -int i; +size_t i; psw_addr =tcg_global_mem_new_i64 (cpu_env, offsetof(CPUS390XState, psw.addr),
target/s390x/tcg/translate.c void s390x_translate_init(void) · line 227
Quoted 8 lines
target/s390x/tcg/translate.c +1
-1@@ -221,7 +221,7 @@ void s390x_translate_init(void) "cc_vr");for (i =0 ; i <16 ; i++) { -snprintf (cpu_reg_names[i],sizeof (cpu_reg_names[0 ]),"r%d" , i); +snprintf (cpu_reg_names[i],sizeof (cpu_reg_names[0 ]),"r%zu" , i); regs[i] =tcg_global_mem_new (cpu_env, offsetof(CPUS390XState, regs[i]), cpu_reg_names[i]);
Ehm, what?
How can "r0" ... "r15" ever consume more than 3 bytes + "\0"?
Signature · 3 lines
Thanks, David / dhildenb