From nobody Fri May 16 04:10:27 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1501063376699188.2039572264457; Wed, 26 Jul 2017 03:02:56 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3DC0F8B13C; Wed, 26 Jul 2017 10:02:52 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0D76E757BD; Wed, 26 Jul 2017 10:02:52 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B70CD180597E; Wed, 26 Jul 2017 10:02:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6QA17lh008866 for ; Wed, 26 Jul 2017 06:01:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 15B886FE76; Wed, 26 Jul 2017 10:01:07 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 682876FE6F; Wed, 26 Jul 2017 10:01:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3DC0F8B13C Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 26 Jul 2017 12:00:42 +0200 Message-Id: <2fd7c56a868d7af8ce77de72a288abc5ec2c34bf.1501062802.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 12/24] qemu: block: Rename qemuBlockFillNodeData and move it to the top X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 26 Jul 2017 10:02:52 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The same operation will become useful in other places so rename the function to be more generic and move it to the top so that it can be reused earlier in the file. --- src/qemu/qemu_block.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 22de70657..3afcbde94 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -27,6 +27,24 @@ #define VIR_FROM_THIS VIR_FROM_QEMU +static int +qemuBlockNamedNodesArrayToHash(size_t pos ATTRIBUTE_UNUSED, + virJSONValuePtr item, + void *opaque) +{ + virHashTablePtr table =3D opaque; + const char *name; + + if (!(name =3D virJSONValueObjectGetString(item, "node-name"))) + return 1; + + if (virHashAddEntry(table, name, item) < 0) + return -1; + + return 0; +} + + static void qemuBlockNodeNameBackingChainDataFree(qemuBlockNodeNameBackingChainDataPtr= data) { @@ -384,24 +402,6 @@ qemuBlockNodeNamesDetect(virQEMUDriverPtr driver, } -static int -qemuBlockFillNodeData(size_t pos ATTRIBUTE_UNUSED, - virJSONValuePtr item, - void *opaque) -{ - virHashTablePtr table =3D opaque; - const char *name; - - if (!(name =3D virJSONValueObjectGetString(item, "node-name"))) - return 1; - - if (virHashAddEntry(table, name, item) < 0) - return -1; - - return 0; -} - - /** * qemuBlockGetNodeData: * @data: JSON object returned from query-named-block-nodes @@ -419,7 +419,7 @@ qemuBlockGetNodeData(virJSONValuePtr data) if (!(ret =3D virHashCreate(50, virJSONValueHashFree))) return NULL; - if (virJSONValueArrayForeachSteal(data, qemuBlockFillNodeData, ret) < = 0) + if (virJSONValueArrayForeachSteal(data, qemuBlockNamedNodesArrayToHash= , ret) < 0) goto error; return ret; --=20 2.13.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list