0a122b
From 5a4f3ccc420f7b6cdce3fc1065119a33e5b0b997 Mon Sep 17 00:00:00 2001
0a122b
Message-Id: <5a4f3ccc420f7b6cdce3fc1065119a33e5b0b997.1387298827.git.minovotn@redhat.com>
0a122b
In-Reply-To: <3ed0fb61a3dc912ef036d7ef450bed192090709e.1387298827.git.minovotn@redhat.com>
0a122b
References: <3ed0fb61a3dc912ef036d7ef450bed192090709e.1387298827.git.minovotn@redhat.com>
0a122b
From: "Michael S. Tsirkin" <mst@redhat.com>
0a122b
Date: Tue, 17 Dec 2013 15:19:18 +0100
0a122b
Subject: [PATCH 52/56] acpi-build: fix build on glib < 2.22
0a122b
0a122b
RH-Author: Michael S. Tsirkin <mst@redhat.com>
0a122b
Message-id: <1387293161-4085-53-git-send-email-mst@redhat.com>
0a122b
Patchwork-id: 56358
0a122b
O-Subject: [PATCH qemu-kvm RHEL7.0 v2 52/57] acpi-build: fix build on glib < 2.22
0a122b
Bugzilla: 1034876
0a122b
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
0a122b
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
0a122b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
0a122b
0a122b
g_string_vprintf was only introduced in 2.24 so switch to vsnprintf
0a122b
instead.  A bit uglier but name size is fixed at 4 bytes here so it's
0a122b
easy.
0a122b
0a122b
Reported-by: Richard Henderson <rth@redhat.com>
0a122b
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
0a122b
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
0a122b
Message-id: 1385036128-8753-1-git-send-email-mst@redhat.com
0a122b
Signed-off-by: Anthony Liguori <aliguori@amazon.com>
0a122b
(cherry picked from commit 542da88f0013ebb2b2d8ca10becbfebd9948abba)
0a122b
---
0a122b
 hw/i386/acpi-build.c | 11 ++++++-----
0a122b
 1 file changed, 6 insertions(+), 5 deletions(-)
0a122b
0a122b
Signed-off-by: Michal Novotny <minovotn@redhat.com>
0a122b
---
0a122b
 hw/i386/acpi-build.c | 11 ++++++-----
0a122b
 1 file changed, 6 insertions(+), 5 deletions(-)
0a122b
0a122b
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
0a122b
index 6cfa044..4e2d709 100644
0a122b
--- a/hw/i386/acpi-build.c
0a122b
+++ b/hw/i386/acpi-build.c
0a122b
@@ -287,16 +287,17 @@ static inline void build_append_array(GArray *array, GArray *val)
0a122b
 
0a122b
 static void build_append_nameseg(GArray *array, const char *format, ...)
0a122b
 {
0a122b
-    GString *s = g_string_new("");
0a122b
+    /* It would be nicer to use g_string_vprintf but it's only there in 2.22 */
0a122b
+    char s[] = "XXXX";
0a122b
+    int len;
0a122b
     va_list args;
0a122b
 
0a122b
     va_start(args, format);
0a122b
-    g_string_vprintf(s, format, args);
0a122b
+    len = vsnprintf(s, sizeof s, format, args);
0a122b
     va_end(args);
0a122b
 
0a122b
-    assert(s->len == 4);
0a122b
-    g_array_append_vals(array, s->str, s->len);
0a122b
-    g_string_free(s, true);
0a122b
+    assert(len == 4);
0a122b
+    g_array_append_vals(array, s, len);
0a122b
 }
0a122b
 
0a122b
 /* 5.4 Definition Block Encoding */
0a122b
-- 
0a122b
1.7.11.7
0a122b