qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for-1.7 1/2] acpi-build: fix build on glib < 2.22
@ 2013-11-21 12:17 Michael S. Tsirkin
  2013-11-21 12:17 ` [Qemu-devel] [PATCH for-1.7 2/2] acpi-build: fix build on glib < 2.14 Michael S. Tsirkin
  2013-11-21 13:51 ` [Qemu-devel] [PATCH for-1.7 1/2] acpi-build: fix build on glib < 2.22 Paolo Bonzini
  0 siblings, 2 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2013-11-21 12:17 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson, Anthony Liguori

g_string_vprintf was only introduced in 2.24 so switch to vsnprintf
instead.  A bit uglier but name size is fixed at 4 bytes here so it's
easy.

Reported-by: Richard Henderson <rth@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/i386/acpi-build.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 486e705..59a17df 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -287,16 +287,17 @@ static inline void build_append_array(GArray *array, GArray *val)
 
 static void build_append_nameseg(GArray *array, const char *format, ...)
 {
-    GString *s = g_string_new("");
+    /* It would be nicer to use g_string_vprintf but it's only there in 2.22 */
+    char s[] = "XXXX";
+    int len;
     va_list args;
 
     va_start(args, format);
-    g_string_vprintf(s, format, args);
+    len = vsnprintf(s, sizeof s, format, args);
     va_end(args);
 
-    assert(s->len == 4);
-    g_array_append_vals(array, s->str, s->len);
-    g_string_free(s, true);
+    assert(len == 4);
+    g_array_append_vals(array, s, len);
 }
 
 /* 5.4 Definition Block Encoding */
-- 
MST

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-11-21 14:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-21 12:17 [Qemu-devel] [PATCH for-1.7 1/2] acpi-build: fix build on glib < 2.22 Michael S. Tsirkin
2013-11-21 12:17 ` [Qemu-devel] [PATCH for-1.7 2/2] acpi-build: fix build on glib < 2.14 Michael S. Tsirkin
2013-11-21 13:54   ` Paolo Bonzini
2013-11-21 14:16     ` Michael S. Tsirkin
2013-11-21 14:16       ` Paolo Bonzini
2013-11-21 13:51 ` [Qemu-devel] [PATCH for-1.7 1/2] acpi-build: fix build on glib < 2.22 Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).