aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2013-11-21 11:19:58 +0200
committerMichael S. Tsirkin <mst@redhat.com>2013-11-21 16:28:21 +0200
commit8b9c3b897c682cd9739c6aef73b3220c7204c243 (patch)
treedeb591099dcb915cf3ec1faaf2ffea1b7386b09e
parent5c397242d5d53c1adecce31817bb439383cf8228 (diff)
acpi-build: fix build on glib < 2.22
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. Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reported-by: Richard Henderson <rth@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r--hw/i386/acpi-build.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 486e7055a6..59a17dfbd3 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 */