From nobody Mon Feb 9 01:21:09 2026 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.zoho.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 1493056852136120.53247273855595; Mon, 24 Apr 2017 11:00:52 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4E591C04B94E; Mon, 24 Apr 2017 18:00:49 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2428B8367F; Mon, 24 Apr 2017 18:00:49 +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 C05E65EC6F; Mon, 24 Apr 2017 18:00:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v3OI0dRH004743 for ; Mon, 24 Apr 2017 14:00:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4442E183C0; Mon, 24 Apr 2017 18:00:39 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-126-74.rdu2.redhat.com [10.10.126.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id 05CCD17A7B for ; Mon, 24 Apr 2017 18:00:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4E591C04B94E Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4E591C04B94E From: John Ferlan To: libvir-list@redhat.com Date: Mon, 24 Apr 2017 14:00:17 -0400 Message-Id: <20170424180023.4695-9-jferlan@redhat.com> In-Reply-To: <20170424180023.4695-1-jferlan@redhat.com> References: <20170424180023.4695-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 08/14] secret: Change variable names for list traversals 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 24 Apr 2017 18:00:50 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than 'nuuids' it should be 'maxuuids' and rather than 'got' it should be 'nuuids'. Alter the logic of the list traversal to utilize those names. Also alter the cleanup in virSecretObjListGetUUIDs to return on success and handle failure with a -1 return instead of the if (ret < 0) logic. Signed-off-by: John Ferlan --- src/conf/virsecretobj.c | 38 +++++++++++++++++--------------------- src/conf/virsecretobj.h | 2 +- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c index 998f815..c410a6b 100644 --- a/src/conf/virsecretobj.c +++ b/src/conf/virsecretobj.c @@ -418,9 +418,9 @@ virSecretObjListAdd(virSecretObjListPtr secrets, struct virSecretObjListGetHelperData { virConnectPtr conn; virSecretObjListACLFilter filter; - int got; - char **uuids; int nuuids; + char **uuids; + int maxuuids; bool error; }; =20 @@ -437,7 +437,7 @@ virSecretObjListGetHelper(void *payload, if (data->error) return 0; =20 - if (data->nuuids >=3D 0 && data->got =3D=3D data->nuuids) + if (data->maxuuids >=3D 0 && data->nuuids =3D=3D data->maxuuids) return 0; =20 virObjectLock(obj); @@ -455,10 +455,10 @@ virSecretObjListGetHelper(void *payload, } =20 virUUIDFormat(def->uuid, uuidstr); - data->uuids[data->got] =3D uuidstr; + data->uuids[data->nuuids] =3D uuidstr; } =20 - data->got++; + data->nuuids++; =20 cleanup: virObjectUnlock(obj); @@ -472,45 +472,41 @@ virSecretObjListNumOfSecrets(virSecretObjListPtr secr= ets, virConnectPtr conn) { struct virSecretObjListGetHelperData data =3D { - .conn =3D conn, .filter =3D filter, .got =3D 0, - .uuids =3D NULL, .nuuids =3D -1, .error =3D false }; + .conn =3D conn, .filter =3D filter, .nuuids =3D 0, + .uuids =3D NULL, .maxuuids =3D -1, .error =3D false }; =20 virObjectLock(secrets); virHashForEach(secrets->objs, virSecretObjListGetHelper, &data); virObjectUnlock(secrets); =20 - return data.got; + return data.nuuids; } =20 =20 int virSecretObjListGetUUIDs(virSecretObjListPtr secrets, char **uuids, - int nuuids, + int maxuuids, virSecretObjListACLFilter filter, virConnectPtr conn) { - int ret =3D -1; - struct virSecretObjListGetHelperData data =3D { - .conn =3D conn, .filter =3D filter, .got =3D 0, - .uuids =3D uuids, .nuuids =3D nuuids, .error =3D false }; + .conn =3D conn, .filter =3D filter, .nuuids =3D 0, + .uuids =3D uuids, .maxuuids =3D maxuuids, .error =3D false }; =20 virObjectLock(secrets); virHashForEach(secrets->objs, virSecretObjListGetHelper, &data); virObjectUnlock(secrets); =20 if (data.error) - goto cleanup; + goto error; =20 - ret =3D data.got; + return data.nuuids; =20 - cleanup: - if (ret < 0) { - while (data.got) - VIR_FREE(data.uuids[--data.got]); - } - return ret; + error: + while (--data.nuuids) + VIR_FREE(data.uuids[data.nuuids]); + return -1; } =20 =20 diff --git a/src/conf/virsecretobj.h b/src/conf/virsecretobj.h index 82915d0..7582913 100644 --- a/src/conf/virsecretobj.h +++ b/src/conf/virsecretobj.h @@ -69,7 +69,7 @@ virSecretObjListNumOfSecrets(virSecretObjListPtr secrets, int virSecretObjListGetUUIDs(virSecretObjListPtr secrets, char **uuids, - int nuuids, + int maxuuids, virSecretObjListACLFilter filter, virConnectPtr conn); =20 --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list