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: 39330 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id ABB3B202DB for ; Wed, 22 Oct 2014 17:41:12 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id d1sf936939wiv.6 for ; Wed, 22 Oct 2014 10:41:11 -0700 (PDT) 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:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=b8DUHI+6wqwmrnAnfom2VE0P5yrP0SwGdAYOO03BImU=; b=LI4ajuUeE5COLIrEdhXNBMQydmPY3jiiFbusL+GIYltZLlJjITmnM+XUMGeG3vFcG1 2eCWWQD/cdHQ39DVJCPdxO7dLqHloMu8gVnLWn2MN0BnfuM8o4sXSQ1+9IKc2Z3HtdaV hhXn16dUcllz8fahDeCs19psgfP5nzXYpCkPugHtQw97TqylHD/A/+znYZcrV5plfDZ+ RI022FR5y2pzzpyrN7Fbqnxrh/7VrsbKDQY2yAD6XvYaW1tm4DDZGVanD/FKB7O5Nu5E R71c3xyRd/Z9TJrJbFUAgtnGpHNhEYhq4orW9j9Pr11xxuOgXVuBY/Y2uvqI4oUMMJUb gDqA== X-Gm-Message-State: ALoCoQkYRUuoJSDGPV0mYM9M6GjYGenYUGlXyehGiRbMSe3Ob8hos2d+ah5uvrpo95WaKa9I6e90 X-Received: by 10.112.99.72 with SMTP id eo8mr3384766lbb.7.1413999671838; Wed, 22 Oct 2014 10:41:11 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.142 with SMTP id j14ls38306laa.5.gmail; Wed, 22 Oct 2014 10:41:11 -0700 (PDT) X-Received: by 10.112.140.8 with SMTP id rc8mr42591102lbb.2.1413999671703; Wed, 22 Oct 2014 10:41:11 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id zw4si24185872lbb.116.2014.10.22.10.41.11 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 22 Oct 2014 10:41:11 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by mail-lb0-f169.google.com with SMTP id 10so3258930lbg.14 for ; Wed, 22 Oct 2014 10:41:11 -0700 (PDT) X-Received: by 10.112.189.10 with SMTP id ge10mr42753323lbc.23.1413999671574; Wed, 22 Oct 2014 10:41:11 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.84.229 with SMTP id c5csp121844lbz; Wed, 22 Oct 2014 10:41:11 -0700 (PDT) X-Received: by 10.194.249.34 with SMTP id yr2mr50300661wjc.9.1413999670947; Wed, 22 Oct 2014 10:41:10 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id ek1si2445216wid.74.2014.10.22.10.41.10 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 22 Oct 2014 10:41:10 -0700 (PDT) Received-SPF: none (google.com: pm215@archaic.org.uk does not designate permitted sender hosts) client-ip=2001:8b0:1d0::1; 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 Cc: patches@linaro.org, Alexander Graf , qemu-ppc@nongnu.org, Alexey Kardashevskiy Subject: [PATCH] hw/ppc/spapr_pci.c: Avoid functions not in glib 2.12 (g_hash_table_iter_*) 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-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org 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.169 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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)