9ae3a8
From e1826a5a94d53d337a0e0e18230d81b572173ba7 Mon Sep 17 00:00:00 2001
9ae3a8
Message-Id: <e1826a5a94d53d337a0e0e18230d81b572173ba7.1387298827.git.minovotn@redhat.com>
9ae3a8
In-Reply-To: <3ed0fb61a3dc912ef036d7ef450bed192090709e.1387298827.git.minovotn@redhat.com>
9ae3a8
References: <3ed0fb61a3dc912ef036d7ef450bed192090709e.1387298827.git.minovotn@redhat.com>
9ae3a8
From: "Michael S. Tsirkin" <mst@redhat.com>
9ae3a8
Date: Tue, 17 Dec 2013 15:19:27 +0100
9ae3a8
Subject: [PATCH 55/56] acpi-build: Fix compiler warning (missing gnu_printf
9ae3a8
 format attribute)
9ae3a8
MIME-Version: 1.0
9ae3a8
Content-Type: text/plain; charset=UTF-8
9ae3a8
Content-Transfer-Encoding: 8bit
9ae3a8
9ae3a8
RH-Author: Michael S. Tsirkin <mst@redhat.com>
9ae3a8
Message-id: <1387293161-4085-56-git-send-email-mst@redhat.com>
9ae3a8
Patchwork-id: 56361
9ae3a8
O-Subject: [PATCH qemu-kvm RHEL7.0 v2 55/57] acpi-build: Fix compiler warning (missing gnu_printf format attribute)
9ae3a8
Bugzilla: 1034876
9ae3a8
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
9ae3a8
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
9ae3a8
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
9ae3a8
From: Stefan Weil <sw@weilnetz.de>
9ae3a8
9ae3a8
gcc 4.8.2 reports this warning when extra warnings are enabled (-Wextra):
9ae3a8
9ae3a8
  CC    m68k-softmmu/hw/m68k/mcf5206.o
9ae3a8
hw/i386/acpi-build.c: In function ‘build_append_nameseg’:
9ae3a8
hw/i386/acpi-build.c:294:5: error:
9ae3a8
 function might be possible candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
9ae3a8
     g_string_vprintf(s, format, args);
9ae3a8
     ^
9ae3a8
9ae3a8
When this warning is fixed, there is a new compiler warning:
9ae3a8
9ae3a8
  CC    i386-softmmu/hw/i386/acpi-build.o
9ae3a8
hw/i386/acpi-build.c: In function ‘build_append_notify’:
9ae3a8
hw/i386/acpi-build.c:632:5: error:
9ae3a8
 format not a string literal and no format arguments [-Werror=format-security]
9ae3a8
     build_append_nameseg(method, name);
9ae3a8
     ^
9ae3a8
9ae3a8
This is fixed here, too.
9ae3a8
9ae3a8
Signed-off-by: Stefan Weil <sw@weilnetz.de>
9ae3a8
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
9ae3a8
(cherry picked from commit 867d898ccf50ef095b95c403d7dc809c188b14e2)
9ae3a8
---
9ae3a8
 hw/i386/acpi-build.c | 5 +++--
9ae3a8
 1 file changed, 3 insertions(+), 2 deletions(-)
9ae3a8
9ae3a8
Signed-off-by: Michal Novotny <minovotn@redhat.com>
9ae3a8
---
9ae3a8
 hw/i386/acpi-build.c | 5 +++--
9ae3a8
 1 file changed, 3 insertions(+), 2 deletions(-)
9ae3a8
9ae3a8
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
9ae3a8
index 316d6d3..2d008bd 100644
9ae3a8
--- a/hw/i386/acpi-build.c
9ae3a8
+++ b/hw/i386/acpi-build.c
9ae3a8
@@ -285,7 +285,8 @@ static inline void build_append_array(GArray *array, GArray *val)
9ae3a8
     g_array_append_vals(array, val->data, val->len);
9ae3a8
 }
9ae3a8
 
9ae3a8
-static void build_append_nameseg(GArray *array, const char *format, ...)
9ae3a8
+static void GCC_FMT_ATTR(2, 3)
9ae3a8
+build_append_nameseg(GArray *array, const char *format, ...)
9ae3a8
 {
9ae3a8
     /* It would be nicer to use g_string_vprintf but it's only there in 2.22 */
9ae3a8
     char s[] = "XXXX";
9ae3a8
@@ -630,7 +631,7 @@ build_append_notify(GArray *device, const char *name,
9ae3a8
     GArray *method = build_alloc_array();
9ae3a8
     uint8_t op = 0x14; /* MethodOp */
9ae3a8
 
9ae3a8
-    build_append_nameseg(method, name);
9ae3a8
+    build_append_nameseg(method, "%s", name);
9ae3a8
     build_append_byte(method, 0x02); /* MethodFlags: ArgCount */
9ae3a8
     for (i = skip; i < count; i++) {
9ae3a8
         GArray *target = build_alloc_array();
9ae3a8
-- 
9ae3a8
1.7.11.7
9ae3a8