[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] qapi: g_hash_table_find() instead of GHashTable
From: |
Erik Rull |
Subject: |
Re: [Qemu-devel] [PATCH] qapi: g_hash_table_find() instead of GHashTableIter. |
Date: |
Tue, 17 Apr 2012 09:51:08 +0200 (CEST) |
On April 13, 2012 at 5:01 PM "NODA, Kai" <address@hidden> wrote:
> From: "NODA, Kai" <address@hidden>
>
> GHashTableIter was first introduced in glib 2.16.
> This patch removes it in favor of older g_hash_table_find()
> for better compatibility with RHEL5.
> ---
> qapi/qmp-input-visitor.c | 25 +++++++++++++++++--------
> 1 file changed, 17 insertions(+), 8 deletions(-)
>
> diff --git a/qapi/qmp-input-visitor.c b/qapi/qmp-input-visitor.c
> index 74386b9..4cdc47d 100644
> --- a/qapi/qmp-input-visitor.c
> +++ b/qapi/qmp-input-visitor.c
> @@ -87,20 +87,29 @@ static void qmp_input_push(QmpInputVisitor *qiv,
QObject *obj, Error **errp)
> qiv->nb_stack++;
> }
>
> +/** Only for qmp_input_pop. */
> +static gboolean always_true(gpointer key, gpointer val, gpointer
user_pkey)
> +{
> + *(const char **)user_pkey = (const char *)key;
> + return TRUE;
> +}
> +
> static void qmp_input_pop(QmpInputVisitor *qiv, Error **errp)
> {
> - GHashTableIter iter;
> - gpointer key;
> + assert(qiv->nb_stack > 0);
>
> - if (qiv->strict && qiv->stack[qiv->nb_stack - 1].h) {
> - g_hash_table_iter_init(&iter, qiv->stack[qiv->nb_stack - 1].h);
> - if (g_hash_table_iter_next(&iter, &key, NULL)) {
> - error_set(errp, QERR_QMP_EXTRA_MEMBER, (char *) key);
> + if (qiv->strict) {
> + GHashTable * const top_ht = qiv->stack[qiv->nb_stack - 1].h;
> + if (top_ht) {
> + if (g_hash_table_size(top_ht)) {
> + const char *key;
> + g_hash_table_find(top_ht, always_true, &key);
> + error_set(errp, QERR_QMP_EXTRA_MEMBER, key);
> + }
> + g_hash_table_unref(top_ht);
> }
> - g_hash_table_unref(qiv->stack[qiv->nb_stack - 1].h);
> }
>
> - assert(qiv->nb_stack > 0);
> qiv->nb_stack--;
> }
>
> --
> 1.7.9.5
>
>
Acked-by: Erik Rull <address@hidden>
compiles on Debian 4.0 and starts on target system.
Best regards,
Erik
- [Qemu-devel] current git master compile fails on Debian 4.0, Erik Rull, 2012/04/10
- Re: [Qemu-devel] current git master compile fails on Debian 4.0, Paolo Bonzini, 2012/04/10
- Re: [Qemu-devel] current git master compile fails on Debian 4.0, Erik Rull, 2012/04/10
- Re: [Qemu-devel] current git master compile fails on Debian 4.0, Kai NODA, 2012/04/12
- [Qemu-devel] [PATCH] qapi: g_hash_table_find() instead of GHashTableIter., NODA, Kai, 2012/04/13
- Re: [Qemu-devel] [PATCH] qapi: g_hash_table_find() instead of GHashTableIter.,
Erik Rull <=
- Re: [Qemu-devel] [PATCH] qapi: g_hash_table_find() instead of GHashTableIter., Luiz Capitulino, 2012/04/17
- [Qemu-devel] [PATCH] qapi: g_hash_table_find() instead of GHashTableIter., NODA, Kai, 2012/04/21
- Re: [Qemu-devel] [PATCH] qapi: g_hash_table_find() instead of GHashTableIter., Luiz Capitulino, 2012/04/23
Re: [Qemu-devel] current git master compile fails on Debian 4.0, Michael Tokarev, 2012/04/10
Re: [Qemu-devel] current git master compile fails on Debian 4.0, Alon Levy, 2012/04/10
Re: [Qemu-devel] current git master compile fails on Debian 4.0, Alon Levy, 2012/04/10