From patchwork Thu Jan 8 17:34:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 42878 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7494B2055F for ; Thu, 8 Jan 2015 17:59:53 +0000 (UTC) Received: by mail-wg0-f70.google.com with SMTP id b13sf2142723wgh.1 for ; Thu, 08 Jan 2015 09:59:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=7toSbCejyIw9Ll6ipBpiD33E7abvu4JQJbPRwNGPDC0=; b=RD7Agt5QJUJNrZJOSD+YSKQcwM4up9R22TnXAbVP1qdiyKAjknli/KK0S4CtHz4vf1 tgxF5iDV5UGtXv8nvU+Hy8fbKFbr+13xE3tO/Ypdn1taat597tnzoglfRAtH0g68Wh5t C6voKgwJDCmXYixA2HyMOhCNl/blEJOKLCghRlpp4yrH4F3KIBz4+uD+MnQw5w09vNjO Dqh2cUwerwdURHefqkZ7+LEOdw2AlAcVhyBWnsbOsGYILqLi5FWQEZCk37lYJMCrIgOy L3sqj9zkpkorGrpMmzrwAWU45UhfmLIXC0hoFE+MG1SOIvxDNuVBhHlfcDhnaHNehYvE ywbg== X-Gm-Message-State: ALoCoQlTF8NXSPpzQxZ2M4J0GBeJvxarppvHmnlap2ExKtQGhLNXm0lzx6Cnds9jBL9ibNcMl+Wy X-Received: by 10.112.118.18 with SMTP id ki18mr435134lbb.15.1420739992519; Thu, 08 Jan 2015 09:59:52 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.39 with SMTP id b7ls335039lae.93.gmail; Thu, 08 Jan 2015 09:59:52 -0800 (PST) X-Received: by 10.152.8.225 with SMTP id u1mr16090530laa.21.1420739992325; Thu, 08 Jan 2015 09:59:52 -0800 (PST) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id y1si9801865lbb.41.2015.01.08.09.59.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 08 Jan 2015 09:59:52 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by mail-lb0-f177.google.com with SMTP id b6so4196780lbj.8 for ; Thu, 08 Jan 2015 09:59:52 -0800 (PST) X-Received: by 10.152.6.132 with SMTP id b4mr16256025laa.59.1420739992037; Thu, 08 Jan 2015 09:59:52 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.9.200 with SMTP id c8csp74724lbb; Thu, 8 Jan 2015 09:59:51 -0800 (PST) X-Received: by 10.140.22.49 with SMTP id 46mr17109785qgm.29.1420739990597; Thu, 08 Jan 2015 09:59:50 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [208.118.235.17]) by mx.google.com with ESMTPS id 48si7914470qgb.58.2015.01.08.09.59.50 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 08 Jan 2015 09:59:50 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; Received: from localhost ([::1]:47299 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9HN7-0005nM-Qf for patch@linaro.org; Thu, 08 Jan 2015 12:59:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60540) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9H04-0004J1-2B for qemu-devel@nongnu.org; Thu, 08 Jan 2015 12:36:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y9Gzo-0006lz-Ku for qemu-devel@nongnu.org; Thu, 08 Jan 2015 12:35:59 -0500 Received: from e39.co.us.ibm.com ([32.97.110.160]:44674) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9Gzn-0006kp-HN for qemu-devel@nongnu.org; Thu, 08 Jan 2015 12:35:43 -0500 Received: from /spool/local by e39.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 8 Jan 2015 10:35:43 -0700 Received: from d01dlp02.pok.ibm.com (9.56.250.167) by e39.co.us.ibm.com (192.168.1.139) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 8 Jan 2015 10:35:40 -0700 Received: from b01cxnp23034.gho.pok.ibm.com (b01cxnp23034.gho.pok.ibm.com [9.57.198.29]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 146516E803F; Thu, 8 Jan 2015 12:27:33 -0500 (EST) Received: from d01av05.pok.ibm.com (d01av05.pok.ibm.com [9.56.224.195]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t08HZduH32243810; Thu, 8 Jan 2015 17:35:39 GMT Received: from d01av05.pok.ibm.com (localhost [127.0.0.1]) by d01av05.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t08HZdg4025787; Thu, 8 Jan 2015 12:35:39 -0500 Received: from localhost (morrigu.austin.ibm.com [9.41.105.45]) by d01av05.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t08HZdZs025771; Thu, 8 Jan 2015 12:35:39 -0500 From: Michael Roth To: qemu-devel@nongnu.org Date: Thu, 8 Jan 2015 11:34:00 -0600 Message-Id: <1420738472-23267-57-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1420738472-23267-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1420738472-23267-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15010817-0033-0000-0000-000003406A7F X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 32.97.110.160 Cc: qemu-stable@nongnu.org Subject: [Qemu-devel] [PATCH 56/88] 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: mdroth@linux.vnet.ibm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Peter Maydell 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. Signed-off-by: Peter Maydell Signed-off-by: Alexander Graf (cherry picked from commit f8833a37c0c6b22ddd57b45e48cfb0f97dbd5af4) Signed-off-by: Michael Roth --- 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 dadba5f..7c18e68 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -700,28 +700,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)