提交 867d898c 编写于 作者: S Stefan Weil 提交者: Michael Tokarev

acpi-build: Fix compiler warning (missing gnu_printf format attribute)

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: NStefan Weil <sw@weilnetz.de>
Signed-off-by: NMichael Tokarev <mjt@tls.msk.ru>
上级 b2e2395f
...@@ -285,7 +285,8 @@ static inline void build_append_array(GArray *array, GArray *val) ...@@ -285,7 +285,8 @@ static inline void build_append_array(GArray *array, GArray *val)
g_array_append_vals(array, val->data, val->len); 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, ...)
{ {
/* It would be nicer to use g_string_vprintf but it's only there in 2.22 */ /* It would be nicer to use g_string_vprintf but it's only there in 2.22 */
char s[] = "XXXX"; char s[] = "XXXX";
...@@ -630,7 +631,7 @@ build_append_notify(GArray *device, const char *name, ...@@ -630,7 +631,7 @@ build_append_notify(GArray *device, const char *name,
GArray *method = build_alloc_array(); GArray *method = build_alloc_array();
uint8_t op = 0x14; /* MethodOp */ uint8_t op = 0x14; /* MethodOp */
build_append_nameseg(method, name); build_append_nameseg(method, "%s", name);
build_append_byte(method, 0x02); /* MethodFlags: ArgCount */ build_append_byte(method, 0x02); /* MethodFlags: ArgCount */
for (i = skip; i < count; i++) { for (i = skip; i < count; i++) {
GArray *target = build_alloc_array(); GArray *target = build_alloc_array();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册