From patchwork Mon Apr 23 16:20:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 154478 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0FFE3B6FC3 for ; Tue, 24 Apr 2012 02:21:19 +1000 (EST) Received: from localhost ([::1]:51435 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SMM0q-0000st-SM for incoming@patchwork.ozlabs.org; Mon, 23 Apr 2012 12:21:16 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51758) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SMM0d-0000YU-8E for qemu-devel@nongnu.org; Mon, 23 Apr 2012 12:21:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SMM0W-0003eC-LY for qemu-devel@nongnu.org; Mon, 23 Apr 2012 12:21:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8167) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SMM0W-0003dJ-CI for qemu-devel@nongnu.org; Mon, 23 Apr 2012 12:20:56 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q3NGKrwF022113 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 23 Apr 2012 12:20:53 -0400 Received: from localhost (ovpn-113-90.phx2.redhat.com [10.3.113.90]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q3NGKqdJ010305; Mon, 23 Apr 2012 12:20:52 -0400 From: Luiz Capitulino To: aliguori@us.ibm.com Date: Mon, 23 Apr 2012 13:20:46 -0300 Message-Id: <1335198046-11713-3-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1335198046-11713-1-git-send-email-lcapitulino@redhat.com> References: <1335198046-11713-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: "NODA, Kai" , qemu-devel@nongnu.org Subject: [Qemu-devel] [PULL 2/2] qapi: g_hash_table_find() instead of GHashTableIter. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: "NODA, Kai" 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. Signed-off-by: NODA, Kai Signed-off-by: Luiz Capitulino --- 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--; }