From: Paolo Bonzini <pbonzini@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: qemu-devel@nongnu.org, Anthony Liguori <aliguori@amazon.com>,
Richard Henderson <rth@redhat.com>
Subject: Re: [Qemu-devel] [PATCH for-1.7 1/2] acpi-build: fix build on glib < 2.22
Date: Thu, 21 Nov 2013 14:51:44 +0100 [thread overview]
Message-ID: <528E0FF0.9090006@redhat.com> (raw)
In-Reply-To: <1385036128-8753-1-git-send-email-mst@redhat.com>
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 <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 */
>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
prev parent reply other threads:[~2013-11-21 13:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Paolo Bonzini [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=528E0FF0.9090006@redhat.com \
--to=pbonzini@redhat.com \
--cc=aliguori@amazon.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.