From patchwork Wed Oct 22 17:41:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 402229 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id EA31014007F for ; Thu, 23 Oct 2014 04:41:41 +1100 (AEDT) Received: from localhost ([::1]:59455 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xgzul-0008AK-R9 for incoming@patchwork.ozlabs.org; Wed, 22 Oct 2014 13:41:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45442) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XgzuR-0007h5-GI for qemu-devel@nongnu.org; Wed, 22 Oct 2014 13:41:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XgzuQ-0008GL-Ji for qemu-devel@nongnu.org; Wed, 22 Oct 2014 13:41:19 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:54271) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XgzuQ-0008F5-BS for qemu-devel@nongnu.org; Wed, 22 Oct 2014 13:41:18 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1XgzuF-0005Yn-N5; Wed, 22 Oct 2014 18:41:07 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Wed, 22 Oct 2014 18:41:07 +0100 Message-Id: <1413999667-21348-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Cc: Alexey Kardashevskiy , qemu-ppc@nongnu.org, Alexander Graf , patches@linaro.org Subject: [Qemu-devel] [PATCH] hw/ppc/spapr_pci.c: Avoid functions not in glib 2.12 (g_hash_table_iter_*) 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 The g_hash_table_iter_* functions for iterating through a hash table are not present in glib 2.12, which is our current minimum requirement. Rewrite the code to use g_hash_table_foreach() instead. Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell --- I have tested that this builds with a glib 2.12, and also that it passes 'make check', but no further testing beyond that. Somebody with an spapr migration test should check it doesn't break things... The observant will note that since this is fixing breakage introduced in commit 9a321e92343 (merged in late June) we obviously released 2.1 in a "doesn't build all targets on glib 2.12" state, and nobody actually complained... So there's maybe scope for debate about moving the minimum version up, but I think for 2.2 we should stick with the current definition. The cc:stable is in the interests of fixing that build breakage in 2.1.x. hw/ppc/spapr_pci.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index ad0da7f..21b95b3 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -704,28 +704,34 @@ static const VMStateDescription vmstate_spapr_pci_msi = { }, }; +static void spapr_pci_fill_msi_devs(gpointer key, gpointer value, + gpointer opaque) +{ + sPAPRPHBState *sphb = opaque; + + sphb->msi_devs[sphb->msi_devs_num].key = *(uint32_t *)key; + sphb->msi_devs[sphb->msi_devs_num].value = *(spapr_pci_msi *)value; + sphb->msi_devs_num++; +} + static void spapr_pci_pre_save(void *opaque) { sPAPRPHBState *sphb = opaque; - GHashTableIter iter; - gpointer key, value; - int i; + int msi_devs_num; if (sphb->msi_devs) { g_free(sphb->msi_devs); sphb->msi_devs = NULL; } - sphb->msi_devs_num = g_hash_table_size(sphb->msi); - if (!sphb->msi_devs_num) { + sphb->msi_devs_num = 0; + msi_devs_num = g_hash_table_size(sphb->msi); + if (!msi_devs_num) { return; } - sphb->msi_devs = g_malloc(sphb->msi_devs_num * sizeof(spapr_pci_msi_mig)); + sphb->msi_devs = g_malloc(msi_devs_num * sizeof(spapr_pci_msi_mig)); - g_hash_table_iter_init(&iter, sphb->msi); - for (i = 0; g_hash_table_iter_next(&iter, &key, &value); ++i) { - sphb->msi_devs[i].key = *(uint32_t *) key; - sphb->msi_devs[i].value = *(spapr_pci_msi *) value; - } + g_hash_table_foreach(sphb->msi, spapr_pci_fill_msi_devs, sphb); + assert(sphb->msi_devs_num == msi_devs_num); } static int spapr_pci_post_load(void *opaque, int version_id)