* [Qemu-trivial] [PATCH for 1.7] acpi-build: Fix compiler warning (missing gnu_printf format attribute)
@ 2013-11-17 18:00 ` Stefan Weil
0 siblings, 0 replies; 8+ messages in thread
From: Stefan Weil @ 2013-11-17 18:00 UTC (permalink / raw)
To: Anthony Liguori; +Cc: qemu-trivial, Stefan Weil, qemu-devel
gcc 4.8.2 reports this warning when extra warnings are enabled (-Wextra):
CC m68k-softmmu/hw/m68k/mcf5206.o
hw/i386/acpi-build.c: In function ‘build_append_nameseg’:
hw/i386/acpi-build.c:294:5: error:
function might be possible candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
g_string_vprintf(s, format, args);
^
When this warning is fixed, there is a new compiler warning:
CC i386-softmmu/hw/i386/acpi-build.o
hw/i386/acpi-build.c: In function ‘build_append_notify’:
hw/i386/acpi-build.c:632:5: error:
format not a string literal and no format arguments [-Werror=format-security]
build_append_nameseg(method, name);
^
This is fixed here, too.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
Note: checkpatch.pl wrongly reports an error.
hw/i386/acpi-build.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 486e705..9fff5ba 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -285,7 +285,8 @@ static inline void build_append_array(GArray *array, GArray *val)
g_array_append_vals(array, val->data, val->len);
}
-static void build_append_nameseg(GArray *array, const char *format, ...)
+static void GCC_FMT_ATTR(2, 3)
+build_append_nameseg(GArray *array, const char *format, ...)
{
GString *s = g_string_new("");
va_list args;
@@ -628,7 +629,7 @@ build_append_notify(GArray *device, const char *name,
GArray *method = build_alloc_array();
uint8_t op = 0x14; /* MethodOp */
- build_append_nameseg(method, name);
+ build_append_nameseg(method, "%s", name);
build_append_byte(method, 0x02); /* MethodFlags: ArgCount */
for (i = skip; i < count; i++) {
GArray *target = build_alloc_array();
--
1.7.10.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH for 1.7] acpi-build: Fix compiler warning (missing gnu_printf format attribute)
@ 2013-11-17 18:00 ` Stefan Weil
0 siblings, 0 replies; 8+ messages in thread
From: Stefan Weil @ 2013-11-17 18:00 UTC (permalink / raw)
To: Anthony Liguori; +Cc: qemu-trivial, Stefan Weil, qemu-devel
gcc 4.8.2 reports this warning when extra warnings are enabled (-Wextra):
CC m68k-softmmu/hw/m68k/mcf5206.o
hw/i386/acpi-build.c: In function ‘build_append_nameseg’:
hw/i386/acpi-build.c:294:5: error:
function might be possible candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
g_string_vprintf(s, format, args);
^
When this warning is fixed, there is a new compiler warning:
CC i386-softmmu/hw/i386/acpi-build.o
hw/i386/acpi-build.c: In function ‘build_append_notify’:
hw/i386/acpi-build.c:632:5: error:
format not a string literal and no format arguments [-Werror=format-security]
build_append_nameseg(method, name);
^
This is fixed here, too.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
Note: checkpatch.pl wrongly reports an error.
hw/i386/acpi-build.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 486e705..9fff5ba 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -285,7 +285,8 @@ static inline void build_append_array(GArray *array, GArray *val)
g_array_append_vals(array, val->data, val->len);
}
-static void build_append_nameseg(GArray *array, const char *format, ...)
+static void GCC_FMT_ATTR(2, 3)
+build_append_nameseg(GArray *array, const char *format, ...)
{
GString *s = g_string_new("");
va_list args;
@@ -628,7 +629,7 @@ build_append_notify(GArray *device, const char *name,
GArray *method = build_alloc_array();
uint8_t op = 0x14; /* MethodOp */
- build_append_nameseg(method, name);
+ build_append_nameseg(method, "%s", name);
build_append_byte(method, 0x02); /* MethodFlags: ArgCount */
for (i = skip; i < count; i++) {
GArray *target = build_alloc_array();
--
1.7.10.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-trivial] [PATCH for 1.7] acpi-build: Fix compiler warning (missing gnu_printf format attribute)
2013-11-17 18:00 ` [Qemu-devel] " Stefan Weil
@ 2013-11-17 20:40 ` Michael Tokarev
-1 siblings, 0 replies; 8+ messages in thread
From: Michael Tokarev @ 2013-11-17 20:40 UTC (permalink / raw)
To: Stefan Weil; +Cc: qemu-trivial, qemu-devel, Anthony Liguori
17.11.2013 22:00, Stefan Weil wrote:
> gcc 4.8.2 reports this warning when extra warnings are enabled (-Wextra):
>
> CC m68k-softmmu/hw/m68k/mcf5206.o
> hw/i386/acpi-build.c: In function ‘build_append_nameseg’:
> hw/i386/acpi-build.c:294:5: error:
> function might be possible candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
> g_string_vprintf(s, format, args);
> ^
Why are you sending for-1.7 patches which fixes issues which are not
present in 1.7? As far as I can see, -Wextra isn't enabled in 1.7, is it?
Thanks,
/mjt
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [Qemu-trivial] [PATCH for 1.7] acpi-build: Fix compiler warning (missing gnu_printf format attribute)
@ 2013-11-17 20:40 ` Michael Tokarev
0 siblings, 0 replies; 8+ messages in thread
From: Michael Tokarev @ 2013-11-17 20:40 UTC (permalink / raw)
To: Stefan Weil; +Cc: qemu-trivial, qemu-devel, Anthony Liguori
17.11.2013 22:00, Stefan Weil wrote:
> gcc 4.8.2 reports this warning when extra warnings are enabled (-Wextra):
>
> CC m68k-softmmu/hw/m68k/mcf5206.o
> hw/i386/acpi-build.c: In function ‘build_append_nameseg’:
> hw/i386/acpi-build.c:294:5: error:
> function might be possible candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
> g_string_vprintf(s, format, args);
> ^
Why are you sending for-1.7 patches which fixes issues which are not
present in 1.7? As far as I can see, -Wextra isn't enabled in 1.7, is it?
Thanks,
/mjt
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-trivial] [PATCH for 1.7] acpi-build: Fix compiler warning (missing gnu_printf format attribute)
2013-11-17 20:40 ` [Qemu-devel] " Michael Tokarev
@ 2013-11-17 21:55 ` Stefan Weil
-1 siblings, 0 replies; 8+ messages in thread
From: Stefan Weil @ 2013-11-17 21:55 UTC (permalink / raw)
To: Michael Tokarev; +Cc: qemu-trivial, qemu-devel, Anthony Liguori
Am 17.11.2013 21:40, schrieb Michael Tokarev:
> 17.11.2013 22:00, Stefan Weil wrote:
>> gcc 4.8.2 reports this warning when extra warnings are enabled (-Wextra):
>>
>> CC m68k-softmmu/hw/m68k/mcf5206.o
>> hw/i386/acpi-build.c: In function ‘build_append_nameseg’:
>> hw/i386/acpi-build.c:294:5: error:
>> function might be possible candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
>> g_string_vprintf(s, format, args);
>> ^
> Why are you sending for-1.7 patches which fixes issues which are not
> present in 1.7? As far as I can see, -Wextra isn't enabled in 1.7, is it?
>
> Thanks,
>
> /mjt
We try to use format attributes for all functions with printf like
arguments.
Patch http://patchwork.ozlabs.org/patch/291873/ shows that the format
attribute
not only fixes a compiler warning (which is not shown with the default
settings)
but also uncovers real programming errors.
I use quite a lot of build environments (32 and 64 bit, Linux and
Windows cross builds)
but there still remain more which I don't cover. With the additional
format attributes
any code either is okay and compiles without warning, or it uses a wrong
format string,
so my patches will break only builds which compile broken code.
I think this kind of build breakage is good and important.
Regards,
Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [Qemu-trivial] [PATCH for 1.7] acpi-build: Fix compiler warning (missing gnu_printf format attribute)
@ 2013-11-17 21:55 ` Stefan Weil
0 siblings, 0 replies; 8+ messages in thread
From: Stefan Weil @ 2013-11-17 21:55 UTC (permalink / raw)
To: Michael Tokarev; +Cc: qemu-trivial, qemu-devel, Anthony Liguori
Am 17.11.2013 21:40, schrieb Michael Tokarev:
> 17.11.2013 22:00, Stefan Weil wrote:
>> gcc 4.8.2 reports this warning when extra warnings are enabled (-Wextra):
>>
>> CC m68k-softmmu/hw/m68k/mcf5206.o
>> hw/i386/acpi-build.c: In function ‘build_append_nameseg’:
>> hw/i386/acpi-build.c:294:5: error:
>> function might be possible candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
>> g_string_vprintf(s, format, args);
>> ^
> Why are you sending for-1.7 patches which fixes issues which are not
> present in 1.7? As far as I can see, -Wextra isn't enabled in 1.7, is it?
>
> Thanks,
>
> /mjt
We try to use format attributes for all functions with printf like
arguments.
Patch http://patchwork.ozlabs.org/patch/291873/ shows that the format
attribute
not only fixes a compiler warning (which is not shown with the default
settings)
but also uncovers real programming errors.
I use quite a lot of build environments (32 and 64 bit, Linux and
Windows cross builds)
but there still remain more which I don't cover. With the additional
format attributes
any code either is okay and compiles without warning, or it uses a wrong
format string,
so my patches will break only builds which compile broken code.
I think this kind of build breakage is good and important.
Regards,
Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-trivial] [PATCH for 1.7] acpi-build: Fix compiler warning (missing gnu_printf format attribute)
2013-11-17 18:00 ` [Qemu-devel] " Stefan Weil
@ 2013-11-20 11:53 ` Michael Tokarev
-1 siblings, 0 replies; 8+ messages in thread
From: Michael Tokarev @ 2013-11-20 11:53 UTC (permalink / raw)
To: Stefan Weil; +Cc: qemu-trivial, qemu-devel, Anthony Liguori
17.11.2013 22:00, Stefan Weil wrote:
> gcc 4.8.2 reports this warning when extra warnings are enabled (-Wextra):
>
> CC m68k-softmmu/hw/m68k/mcf5206.o
> hw/i386/acpi-build.c: In function ‘build_append_nameseg’:
> hw/i386/acpi-build.c:294:5: error:
> function might be possible candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
> g_string_vprintf(s, format, args);
> ^
>
> When this warning is fixed, there is a new compiler warning:
>
> CC i386-softmmu/hw/i386/acpi-build.o
> hw/i386/acpi-build.c: In function ‘build_append_notify’:
> hw/i386/acpi-build.c:632:5: error:
> format not a string literal and no format arguments [-Werror=format-security]
> build_append_nameseg(method, name);
> ^
>
> This is fixed here, too.
Thanks, applied to the trivial-patches queue.
Note this patch also triggers checkpatch.pl error:
> +static void GCC_FMT_ATTR(2, 3)
> +build_append_nameseg(GArray *array, const char *format, ...)
^
ERROR: need consistent spacing around '*' (ctx:WxV)
#40: FILE: hw/i386/acpi-build.c:289:
It looks like checkpatch.pl needs some tweaking here, because
the spacing here is really consistent, as far as I can see.
/mjt
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [Qemu-trivial] [PATCH for 1.7] acpi-build: Fix compiler warning (missing gnu_printf format attribute)
@ 2013-11-20 11:53 ` Michael Tokarev
0 siblings, 0 replies; 8+ messages in thread
From: Michael Tokarev @ 2013-11-20 11:53 UTC (permalink / raw)
To: Stefan Weil; +Cc: qemu-trivial, qemu-devel, Anthony Liguori
17.11.2013 22:00, Stefan Weil wrote:
> gcc 4.8.2 reports this warning when extra warnings are enabled (-Wextra):
>
> CC m68k-softmmu/hw/m68k/mcf5206.o
> hw/i386/acpi-build.c: In function ‘build_append_nameseg’:
> hw/i386/acpi-build.c:294:5: error:
> function might be possible candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
> g_string_vprintf(s, format, args);
> ^
>
> When this warning is fixed, there is a new compiler warning:
>
> CC i386-softmmu/hw/i386/acpi-build.o
> hw/i386/acpi-build.c: In function ‘build_append_notify’:
> hw/i386/acpi-build.c:632:5: error:
> format not a string literal and no format arguments [-Werror=format-security]
> build_append_nameseg(method, name);
> ^
>
> This is fixed here, too.
Thanks, applied to the trivial-patches queue.
Note this patch also triggers checkpatch.pl error:
> +static void GCC_FMT_ATTR(2, 3)
> +build_append_nameseg(GArray *array, const char *format, ...)
^
ERROR: need consistent spacing around '*' (ctx:WxV)
#40: FILE: hw/i386/acpi-build.c:289:
It looks like checkpatch.pl needs some tweaking here, because
the spacing here is really consistent, as far as I can see.
/mjt
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-11-20 11:53 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-17 18:00 [Qemu-trivial] [PATCH for 1.7] acpi-build: Fix compiler warning (missing gnu_printf format attribute) Stefan Weil
2013-11-17 18:00 ` [Qemu-devel] " Stefan Weil
2013-11-17 20:40 ` [Qemu-trivial] " Michael Tokarev
2013-11-17 20:40 ` [Qemu-devel] " Michael Tokarev
2013-11-17 21:55 ` Stefan Weil
2013-11-17 21:55 ` [Qemu-devel] " Stefan Weil
2013-11-20 11:53 ` Michael Tokarev
2013-11-20 11:53 ` [Qemu-devel] " Michael Tokarev
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.