Skip to content

Commit

Permalink
acpi-build: fix build on glib < 2.22
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mstsirkin committed Nov 21, 2013
1 parent 5c39724 commit 8b9c3b8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions hw/i386/acpi-build.c
Expand Up @@ -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 */
Expand Down

0 comments on commit 8b9c3b8

Please sign in to comment.