All of lore.kernel.org
 help / color / mirror / Atom feed
* [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

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.