From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjUfp-0004qD-2D for qemu-devel@nongnu.org; Thu, 21 Nov 2013 08:52:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VjUff-00029b-DV for qemu-devel@nongnu.org; Thu, 21 Nov 2013 08:52:00 -0500 Received: from mail-qc0-x22a.google.com ([2607:f8b0:400d:c01::22a]:49445) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjUff-00029J-95 for qemu-devel@nongnu.org; Thu, 21 Nov 2013 08:51:51 -0500 Received: by mail-qc0-f170.google.com with SMTP id e20so4214458qcy.29 for ; Thu, 21 Nov 2013 05:51:50 -0800 (PST) Sender: Paolo Bonzini Message-ID: <528E0FF0.9090006@redhat.com> Date: Thu, 21 Nov 2013 14:51:44 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1385036128-8753-1-git-send-email-mst@redhat.com> In-Reply-To: <1385036128-8753-1-git-send-email-mst@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH for-1.7 1/2] acpi-build: fix build on glib < 2.22 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: qemu-devel@nongnu.org, Anthony Liguori , Richard Henderson Il 21/11/2013 13:17, Michael S. Tsirkin ha scritto: > 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 > Signed-off-by: Michael S. Tsirkin > --- > 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 */ > Reviewed-by: Paolo Bonzini