Received: from eggs.gnu.org ([2001:4830:134:3::10]:50579) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z56pS-0006dX-HM for qemu-devel@nongnu.org; Wed, 17 Jun 2015 02:28:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z56pM-0007T0-RR for qemu-devel@nongnu.org; Wed, 17 Jun 2015 02:28:06 -0400 Date: Wed, 17 Jun 2015 08:27:53 +0200 From: Thomas Huth Message-ID: <20150617082753.671d9ec4@thh440s> In-Reply-To: <1432749176-4781-1-git-send-email-armbru@redhat.com> References: <1432749176-4781-1-git-send-email-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] Revert "hw/ppc/spapr_pci.c: Avoid functions not in glib 2.12 (g_hash_table_iter_*)" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: david@gibson.dropbear.id.au, qemu-ppc@nongnu.org, qemu-devel@nongnu.org, agraf@suse.de On Wed, 27 May 2015 19:52:56 +0200 Markus Armbruster wrote: > Since we now require GLib 2.22+ (commit f40685c), we don't have to > work around lack of g_hash_table_iter_init() & friends anymore. > > This reverts commit f8833a37c0c6b22ddd57b45e48cfb0f97dbd5af4. > > Signed-off-by: Markus Armbruster > --- > hw/ppc/spapr_pci.c | 28 +++++++++++----------------- > 1 file changed, 11 insertions(+), 17 deletions(-) > > diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c > index 05f4fac..e2b9e60 100644 > --- a/hw/ppc/spapr_pci.c > +++ b/hw/ppc/spapr_pci.c > @@ -962,34 +962,28 @@ 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; > - int msi_devs_num; > + GHashTableIter iter; > + gpointer key, value; > + int i; > > if (sphb->msi_devs) { > g_free(sphb->msi_devs); > sphb->msi_devs = NULL; > } > - sphb->msi_devs_num = 0; > - msi_devs_num = g_hash_table_size(sphb->msi); > - if (!msi_devs_num) { > + sphb->msi_devs_num = g_hash_table_size(sphb->msi); > + if (!sphb->msi_devs_num) { > return; > } > - sphb->msi_devs = g_malloc(msi_devs_num * sizeof(spapr_pci_msi_mig)); > + sphb->msi_devs = g_malloc(sphb->msi_devs_num * sizeof(spapr_pci_msi_mig)); > > - g_hash_table_foreach(sphb->msi, spapr_pci_fill_msi_devs, sphb); > - assert(sphb->msi_devs_num == msi_devs_num); > + 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; > + } > } > > static int spapr_pci_post_load(void *opaque, int version_id) Reviewed-by: Thomas Huth