yeahuh / rpms / qemu-kvm

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