From patchwork Tue Nov 4 19:26:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 40165 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6E5EA21894 for ; Tue, 4 Nov 2014 19:41:12 +0000 (UTC) Received: by mail-la0-f69.google.com with SMTP id q1sf1077037lam.0 for ; Tue, 04 Nov 2014 11:41:11 -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=VJCGGQsHsYMD4kUpWskAuOnpKLhUEsY0PilV0hL5I9Q=; b=WaAWZswojXS4pJeDB+pYauwttBIF7J9UpIsejNBhBhCOGLYJECdPOHBK8YbCz0NS7d 4cANQNBpaiMgn1I+Y2nGTrW0GdrSd0Dj2Gk1xqp22HoGebLbZwiynsxqpw3XJkx/KggL J/xqH4SZfXVSYmf50toGDrb2DHZxvvmUUw0EqkhYouAwm1HZeh1cihD8tSFDTLxwwOZn V7vKOrVaSayFXtoEN+WitUOGs5ZOmknLenkjjPiqp0eLErph5vJ33Y1p2jmaaD0s4YGP Lu+gVtARbgxYWizEv2dlipEgy7hjs1SzBuSl3QctHrM31rDkpAy8/vguwpaIP8tb8JAv aoCw== X-Gm-Message-State: ALoCoQknHPZWFUL10khImIR3X3KjGWG4NH1AP5jaBRJSlGO67I0mxYdrFozz63fJCQeZak0e5gWG X-Received: by 10.112.146.104 with SMTP id tb8mr3813lbb.22.1415130071341; Tue, 04 Nov 2014 11:41:11 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.25.165 with SMTP id d5ls913731lag.1.gmail; Tue, 04 Nov 2014 11:41:10 -0800 (PST) X-Received: by 10.112.134.39 with SMTP id ph7mr61859199lbb.45.1415130070649; Tue, 04 Nov 2014 11:41:10 -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 q20si2193755lal.130.2014.11.04.11.41.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 04 Nov 2014 11:41:10 -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 z12so3250500lbi.22 for ; Tue, 04 Nov 2014 11:41:10 -0800 (PST) X-Received: by 10.112.14.69 with SMTP id n5mr61439999lbc.34.1415130070504; Tue, 04 Nov 2014 11:41:10 -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.184.201 with SMTP id ew9csp178929lbc; Tue, 4 Nov 2014 11:41:09 -0800 (PST) X-Received: by 10.140.105.37 with SMTP id b34mr74842632qgf.91.1415130069060; Tue, 04 Nov 2014 11:41:09 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id j11si2410129qge.38.2014.11.04.11.41.08 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 04 Nov 2014 11:41:09 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:42584 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XljyW-0000J2-Aa for patch@linaro.org; Tue, 04 Nov 2014 14:41:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36410) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xljl0-00022Z-6k for qemu-devel@nongnu.org; Tue, 04 Nov 2014 14:27:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xljkl-00080T-Fa for qemu-devel@nongnu.org; Tue, 04 Nov 2014 14:27:10 -0500 Received: from cantor2.suse.de ([195.135.220.15]:56001 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xljkl-0007z8-8b; Tue, 04 Nov 2014 14:26:55 -0500 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 856BBAD9F; Tue, 4 Nov 2014 19:26:54 +0000 (UTC) From: Alexander Graf To: qemu-ppc@nongnu.org Date: Tue, 4 Nov 2014 20:26:40 +0100 Message-Id: <1415129211-9740-23-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1415129211-9740-1-git-send-email-agraf@suse.de> References: <1415129211-9740-1-git-send-email-agraf@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 195.135.220.15 Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org Subject: [Qemu-devel] [PULL 22/33] 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: agraf@suse.de 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 --- 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)