From nobody Mon May 6 11:33:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601898590; cv=none; d=zohomail.com; s=zohoarc; b=B/H40PDrv2J1AFNE64avJ2QArLExrXCRYSarhP+9JEOHvZQn+MC8nkXIHiOLNRDVu2m7U1Q+ohJl+D7WagLs6ZLACLZVuSAtAaqVTS8rGsfyaU8Z+PhpjS/q2bVwD93+iyf3JXE0v85xY32bVSonRYaAPXzLxQQ2k8fzF9JEPcg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601898590; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Gf/dJAunQ/T57i51fi9ANra6zzS/L6lALNS4eNSM/GE=; b=EPirXEgt+O9SDG1zc/HjvQ/xphKuF1kAwiEYbc10uiH0A67EzvnTPqPeK5C2TYsRkUxXCrzB4cX4aDkPdKFbA8bpCLlgPIyrfao0dm8UHCiPQ8MqiaueHyBggl/NFb6FAF37TrHG5DRQec4VSvWHmpOvfnxZxh9RYQP1gsZsWIg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1601898590265184.03066879297364; Mon, 5 Oct 2020 04:49:50 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-507-m-NEXFyKOIWWAwgW3YjNWg-1; Mon, 05 Oct 2020 07:49:46 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id EC5B910866A7; Mon, 5 Oct 2020 11:49:40 +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 A9C4A78826; Mon, 5 Oct 2020 11:49:40 +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 CB305181A870; Mon, 5 Oct 2020 11:49:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 095BndUb028043 for ; Mon, 5 Oct 2020 07:49:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2C63B26185; Mon, 5 Oct 2020 11:49:39 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 79AF819C4F for ; Mon, 5 Oct 2020 11:49:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601898589; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Gf/dJAunQ/T57i51fi9ANra6zzS/L6lALNS4eNSM/GE=; b=PxK2bKqMMXI2hufWCGUey/5BQCcADkEREu1966aPc+1q+j8M+WHpoaeNLyamkQkqjrbWzc yz35ZaWnZMlVocMUUMiS8oV8umGRvm87zm5D1yftJPJNfWcZufQhrCnvNwUYvDX1iDK2/X LhaePHvahjgoRHrvkuXhyoTlzKXqPFY= X-MC-Unique: m-NEXFyKOIWWAwgW3YjNWg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 1/7] virbitmaptest: Split up test12 Date: Mon, 5 Oct 2020 13:49:23 +0200 Message-Id: <00268915eb5043f8598e5887672fb8a8a1868f24.1601898456.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" 'test12' was testing two distinct operations on two instances of a bitmap. Split it up into 'test12a' and 'test12b' so that the 'bitmap' variable is not reused. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virbitmaptest.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c index 687b5f87af..32187ebec4 100644 --- a/tests/virbitmaptest.c +++ b/tests/virbitmaptest.c @@ -629,7 +629,7 @@ test11(const void *opaque) /* test self-expanding bitmap APIs */ static int -test12(const void *opaque G_GNUC_UNUSED) +test12a(const void *opaque G_GNUC_UNUSED) { virBitmapPtr map =3D virBitmapNewEmpty(); int ret =3D -1; @@ -646,7 +646,20 @@ test12(const void *opaque G_GNUC_UNUSED) TEST_MAP(151, "128"); + ret =3D 0; + + cleanup: virBitmapFree(map); + return ret; +} + + +static int +test12b(const void *opaque G_GNUC_UNUSED) +{ + virBitmapPtr map =3D virBitmapNewEmpty(); + int ret =3D -1; + if (!(map =3D virBitmapParseUnlimited("34,1023"))) goto cleanup; @@ -829,7 +842,9 @@ mymain(void) TESTBINARYOP("0-3", "0,^0", "0,^0", test11); TESTBINARYOP("0,2", "1,3", "0,^0", test11); - if (virTestRun("test12", test12, NULL) < 0) + if (virTestRun("test12a", test12a, NULL) < 0) + ret =3D -1; + if (virTestRun("test12b", test12b, NULL) < 0) ret =3D -1; if (virTestRun("test13", test13, NULL) < 0) ret =3D -1; --=20 2.26.2 From nobody Mon May 6 11:33:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601898597; cv=none; d=zohomail.com; s=zohoarc; b=WUsQmbcD2pxqxBCxFZo9JQSE+aEO6Ye5maJZ6J8PT1i3Ix7DtVrq5KR7f0EZCKk5M2p78GDq3wzMDQol2pVYv1Dn9w19NGWx+Cu2dX7c5k8n5MK5KgdnEn544neaJUifoNeWl4MP1SDsryT0F8Z8PY9FP7U18kGIVOo4xmRJXQ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601898597; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MMYLjiySFENwUnIIZ3yNJ4AiRFGqtOo/HKMy3vfSueE=; b=UL7qugTLFxh0ncUf3eQjkA1sXwIH+JgHsw1PPHCOFUrzlpHCcTSX/nZ1l8rKH01ZLZ7vaex7GTh4EsEOXyUbBAR5+3GC4Ur5gmqCSm1ahWnbZzbN6qFciaB0zAdI+jUTI/q5S8KCjS2FcxpwaVm1k67wlkIPtlw+EfiU8CEyR6A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1601898597494499.0111155865951; Mon, 5 Oct 2020 04:49:57 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-519-MW9NdRqkPCyehDY_2AxXcg-1; Mon, 05 Oct 2020 07:49:54 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E418D1019626; Mon, 5 Oct 2020 11:49:47 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C31F655767; Mon, 5 Oct 2020 11:49:47 +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 92FED44A5E; Mon, 5 Oct 2020 11:49:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 095BneTa028049 for ; Mon, 5 Oct 2020 07:49:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3ADCA19C4F; Mon, 5 Oct 2020 11:49:40 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 976F42635E for ; Mon, 5 Oct 2020 11:49:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601898596; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=MMYLjiySFENwUnIIZ3yNJ4AiRFGqtOo/HKMy3vfSueE=; b=CLiD2MCk3xUpubK8Sj+Xj1b0f7bRpVvJD/RTaFDGyKGOk/UzCoL+LHZfZhC74880EIq6Iz 08qR26zaFdc7ERIrB3aPr5eG8Js7VR1eCRumIAaLuKS0jiXz8k/OYec6NGBi5ZOmft/85k w3B03tRADG0v1wsl9vf2MVPm6Vn6DQE= X-MC-Unique: MW9NdRqkPCyehDY_2AxXcg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 2/7] virbitmaptest: Split up test4 Date: Mon, 5 Oct 2020 13:49:24 +0200 Message-Id: <1c94ce57d22501f2796065f1a98f5bbeb62736d0.1601898456.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" 'test4' was testing three distinct operations on separate instances of a bitmap. Split it up into 'test4a', 'test4b' and 'test4c' so that the 'bitmap' variable is not reused. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virbitmaptest.c | 64 +++++++++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c index 32187ebec4..98ac06c406 100644 --- a/tests/virbitmaptest.c +++ b/tests/virbitmaptest.c @@ -173,23 +173,9 @@ test3(const void *data G_GNUC_UNUSED) /* test for virBitmapNextSetBit, virBitmapLastSetBit, virBitmapNextClearBi= t */ static int -test4(const void *data G_GNUC_UNUSED) +test4a(const void *data G_GNUC_UNUSED) { - const char *bitsString =3D "0, 2-4, 6-10, 12, 14-18, 20, 22, 25"; - int size =3D 40; - int bitsPos[] =3D { - 0, 2, 3, 4, 6, 7, 8, 9, 10, 12, - 14, 15, 16, 17, 18, 20, 22, 25 - }; - int bitsPosInv[] =3D { - 1, 5, 11, 13, 19, 21, 23, 24, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39 - }; virBitmapPtr bitmap =3D NULL; - ssize_t i, j; - - if (G_N_ELEMENTS(bitsPos) + G_N_ELEMENTS(bitsPosInv) !=3D size) - goto error; /* 0. empty set */ @@ -205,7 +191,20 @@ test4(const void *data G_GNUC_UNUSED) goto error; virBitmapFree(bitmap); - bitmap =3D NULL; + return 0; + + error: + virBitmapFree(bitmap); + return -1; +} + + +static int +test4b(const void *data G_GNUC_UNUSED) +{ + virBitmapPtr bitmap =3D NULL; + int size =3D 40; + size_t i; /* 1. zero set */ @@ -230,7 +229,32 @@ test4(const void *data G_GNUC_UNUSED) goto error; virBitmapFree(bitmap); - bitmap =3D NULL; + return 0; + + error: + virBitmapFree(bitmap); + return -1; +} + + +static int +test4c(const void *data G_GNUC_UNUSED) +{ + const char *bitsString =3D "0, 2-4, 6-10, 12, 14-18, 20, 22, 25"; + int size =3D 40; + int bitsPos[] =3D { + 0, 2, 3, 4, 6, 7, 8, 9, 10, 12, + 14, 15, 16, 17, 18, 20, 22, 25 + }; + int bitsPosInv[] =3D { + 1, 5, 11, 13, 19, 21, 23, 24, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39 + }; + virBitmapPtr bitmap =3D NULL; + ssize_t i, j; + + if (G_N_ELEMENTS(bitsPos) + G_N_ELEMENTS(bitsPosInv) !=3D size) + goto error; /* 2. partial set */ @@ -818,7 +842,11 @@ mymain(void) ret =3D -1; if (virTestRun("test3", test3, NULL) < 0) ret =3D -1; - if (virTestRun("test4", test4, NULL) < 0) + if (virTestRun("test4a", test4a, NULL) < 0) + ret =3D -1; + if (virTestRun("test4b", test4b, NULL) < 0) + ret =3D -1; + if (virTestRun("test4c", test4c, NULL) < 0) ret =3D -1; if (virTestRun("test5", test5, NULL) < 0) ret =3D -1; --=20 2.26.2 From nobody Mon May 6 11:33:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601898672; cv=none; d=zohomail.com; s=zohoarc; b=kpNk7k/HAAI7JfGkR7Fqs5lQkr/sQk9woj7DkTXDVwiRGYawkyg24quIqsXnP+Kf899BhgMxV+dXzr9vEAFX5OjDZwILXpYF32577rEOeZO9+PF9SL2kUzo9Qddx5U6cPVIdAFP7vtqBUWnl8tyVwbJtqiWpN07tt5lGoh81ons= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601898672; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lsZUVGI1JW2Cgd/50xz31mQ2ZWih61hNSSNIfYOtNEI=; b=kPamzukCHsPOR5x0G2CK5UJ3uPdAG2P7LiTQjV42RIE0nGCVoaoFxJwWF7CzvKG37jI2fOU9GXWvZDWDWrLhDDd9s0Gv5ZoitdBQYD59lRKcfzuLq/3o8b4ri+IVgVCqn25GuoF45rTJ35h0wCSg2oblEAVAX5LuraXL5b/irYM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1601898672844324.74400707780444; Mon, 5 Oct 2020 04:51:12 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-138-4gGrfM6MMPKA_dQXmpbLWg-1; Mon, 05 Oct 2020 07:49:55 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BE5DE64081; Mon, 5 Oct 2020 11:49:48 +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 956905C1BD; Mon, 5 Oct 2020 11:49:48 +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 5FE94181A884; Mon, 5 Oct 2020 11:49:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 095BnfxO028062 for ; Mon, 5 Oct 2020 07:49:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 51A5119C4F; Mon, 5 Oct 2020 11:49:41 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E5622635E for ; Mon, 5 Oct 2020 11:49:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601898671; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=lsZUVGI1JW2Cgd/50xz31mQ2ZWih61hNSSNIfYOtNEI=; b=GJWqb3ZKl4pu9RRP1Ky5A/T4XivwdOKf7RA4M4ZAxSuiuvAv2NkfZFVlphxbZX02+8SqML MAd4DQU5SDeRNN2AMIrIHhisESbIuI3z8D5agam7wSd5jhDWuM4Ma6kgl9jxyzYeiv1lku CeHj8DKe8bKNfu1HXax+v47EXcm7DW8= X-MC-Unique: 4gGrfM6MMPKA_dQXmpbLWg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 3/7] virbitmaptest: Use separate output strings in 'test5' Date: Mon, 5 Oct 2020 13:49:25 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The test validates two outputs. Don't reuse 'str' for both. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virbitmaptest.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c index 98ac06c406..dc23431645 100644 --- a/tests/virbitmaptest.c +++ b/tests/virbitmaptest.c @@ -329,7 +329,8 @@ test5(const void *v G_GNUC_UNUSED) size_t i; ssize_t j; int ret =3D -1; - char *str =3D NULL; + g_autofree char *actual1 =3D NULL; + g_autofree char *actual2 =3D NULL; bitmap =3D virBitmapNewData(data, sizeof(data)); if (!bitmap) @@ -359,19 +360,17 @@ test5(const void *v G_GNUC_UNUSED) data2[4] !=3D 0x04) goto error; - if (!(str =3D virBitmapDataFormat(data, sizeof(data)))) + if (!(actual1 =3D virBitmapDataFormat(data, sizeof(data)))) goto error; - if (STRNEQ(str, "0,9,34")) + if (STRNEQ(actual1, "0,9,34")) goto error; - VIR_FREE(str); - if (!(str =3D virBitmapDataFormat(data2, len2))) + if (!(actual2 =3D virBitmapDataFormat(data2, len2))) goto error; - if (STRNEQ(str, "0,2,9,15,34")) + if (STRNEQ(actual2, "0,2,9,15,34")) goto error; ret =3D 0; error: - VIR_FREE(str); virBitmapFree(bitmap); VIR_FREE(data2); return ret; --=20 2.26.2 From nobody Mon May 6 11:33:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601898597; cv=none; d=zohomail.com; s=zohoarc; b=Bn5nnlOTFOhcdauZI/3TIpA895w7OHioFZNJbRhtMcdZIGDASs5XwfP+/AvnJlYXNSoLfYz/7Pp7fN2pChHcGWU+AnwWjhTsoQbaNzLDGv5+gX7A5V705W6SEdc3Haau9cob+p6cAi+YF7tQdTaCwrHzI5BtkyadXJLCMNMjMbw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601898597; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gkD+SQjcAlQdZMH8l0MtLF5GwuWLAHtQV0KpwbTaXbE=; b=P+WXbbhGtvVc1Cx41ldICmrVcChT+wNm5akPB4jNGKpWxpMO2b0ft3yPPe5xbl9Ui2ycAV/WZOvJLb8yJ4d1KR8pjfQMspzmO5T/dUB8CBCqjIaMLABzCnUy+ix1k4WoB9Iva7SwuRLip7CtbMCD2idePHL1RUZxs+HLOUls1m0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1601898597273697.642493596538; Mon, 5 Oct 2020 04:49:57 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-593-etiZ8WlhMAaPNpL5mCVRGQ-1; Mon, 05 Oct 2020 07:49:53 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1C174801AE1; Mon, 5 Oct 2020 11:49:47 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E3E675C1BD; Mon, 5 Oct 2020 11:49:46 +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 A51DC44A5F; Mon, 5 Oct 2020 11:49:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 095BngEn028069 for ; Mon, 5 Oct 2020 07:49:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id AD92A19C4F; Mon, 5 Oct 2020 11:49:42 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0CABD277CF for ; Mon, 5 Oct 2020 11:49:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601898595; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=gkD+SQjcAlQdZMH8l0MtLF5GwuWLAHtQV0KpwbTaXbE=; b=LbHwVpcF5KXJshlN9Cv4vUa7yd4FSEZ4ZC4gKqL9OQ8oXom5DiRFTgOzEGbE5k790p/CBx 8QCHFkLMSOXrTjynl8I9MZpooH7q53Rbpa9MZycj1ACfGUjszPsPVs7/zIvPJB9vZtH5xz csZq8fM80LQdxN0zP/4HMGmEHL1rxx4= X-MC-Unique: etiZ8WlhMAaPNpL5mCVRGQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 4/7] virbitmaptest: Turn 'TEST_MAP' macro into a helper function Date: Mon, 5 Oct 2020 13:49:26 +0200 Message-Id: <815ed58426644ec8f22807606a82f6dfc88bf3d8.1601898456.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The function will also be reusable in other places of the code by making the size check optional. For now only test12* is refactored since it used TEST_MAP directly. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virbitmaptest.c | 63 +++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c index dc23431645..c16be62e23 100644 --- a/tests/virbitmaptest.c +++ b/tests/virbitmaptest.c @@ -26,6 +26,31 @@ #include "virbitmap.h" + +static int +checkBitmap(virBitmapPtr map, + const char *expect, + ssize_t expectedSize) +{ + g_autofree char *actual =3D virBitmapFormat(map); + + if (expectedSize !=3D -1 && + virBitmapSize(map) !=3D expectedSize) { + fprintf(stderr, "\n expected bitmap size: '%zd' actual size: " + "'%zu'\n", expectedSize, virBitmapSize(map)); + return -1; + } + + if (STRNEQ_NULLABLE(expect, actual)) { + fprintf(stderr, "\n expected bitmap contents '%s' actual contents = "\ + "'%s'\n", NULLSTR(expect), NULLSTR(actual)); + return -1; + } + + return 0; +} + + static int test1(const void *data G_GNUC_UNUSED) { @@ -630,25 +655,6 @@ test11(const void *opaque) return ret; } -#define TEST_MAP(sz, expect) \ - do { \ - char *actual; \ - if (virBitmapSize(map) !=3D sz) { \ - fprintf(stderr, "\n expected bitmap size: '%d' actual size: " \ - "'%zu'\n", sz, virBitmapSize(map)); \ - goto cleanup; \ - } \ - \ - actual =3D virBitmapFormat(map); \ - \ - if (STRNEQ_NULLABLE(expect, actual)) { \ - fprintf(stderr, "\n expected bitmap contents '%s' actual conte= nts "\ - "'%s'\n", NULLSTR(expect), NULLSTR(actual)); \ - VIR_FREE(actual); \ - goto cleanup; \ - } \ - VIR_FREE(actual); \ - } while (0) /* test self-expanding bitmap APIs */ static int @@ -657,17 +663,20 @@ test12a(const void *opaque G_GNUC_UNUSED) virBitmapPtr map =3D virBitmapNewEmpty(); int ret =3D -1; - TEST_MAP(0, ""); + if (checkBitmap(map, "", 0) < 0) + goto cleanup; if (virBitmapSetBitExpand(map, 128) < 0) goto cleanup; - TEST_MAP(129, "128"); + if (checkBitmap(map, "128", 129) < 0) + goto cleanup; if (virBitmapClearBitExpand(map, 150) < 0) goto cleanup; - TEST_MAP(151, "128"); + if (checkBitmap(map, "128", 151) < 0) + goto cleanup; ret =3D 0; @@ -686,13 +695,16 @@ test12b(const void *opaque G_GNUC_UNUSED) if (!(map =3D virBitmapParseUnlimited("34,1023"))) goto cleanup; - TEST_MAP(1024, "34,1023"); + if (checkBitmap(map, "34,1023", 1024) < 0) + goto cleanup; virBitmapShrink(map, 35); - TEST_MAP(35, "34"); + if (checkBitmap(map, "34", 35) < 0) + goto cleanup; virBitmapShrink(map, 34); - TEST_MAP(34, ""); + if (checkBitmap(map, "", 34) < 0) + goto cleanup; ret =3D 0; @@ -729,7 +741,6 @@ test13(const void *opaque G_GNUC_UNUSED) return 0; } -#undef TEST_MAP static int test14(const void *opaque) --=20 2.26.2 From nobody Mon May 6 11:33:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601898601; cv=none; d=zohomail.com; s=zohoarc; b=Nvc8nVSDtMq2PCvmZFTH1a4xSpUfOr2smPqXGm32Wdg0IGO9qzxVTzmIiLDWtgZGODNOHydLXUOMLgRDJaXjuRmYykO8hqAbdlWmyhv8iNh9VH2I+aEqur86qnxBO2pjVTNFGAXveqFJSsMTPLjuuMLegNdGmAGi4JUBU6jWa1M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601898601; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zw2pe5cAJ6JzWK0eZkSCfhchxuorlCxAb47L4QOmOrA=; b=AHD+xmSbg31Wh04H4kgBoa3WNe9Gs199afJUGSdgVwwQvun94sJVddVtuTP6mWyJDuWsa8HXV2dOLJLUkr2+lfj0M4nLrZn5B5UFUQIjOOr41vKRiAlAB8eqXiL2fieQUu0/arSORDPLKMq1PCCwzjrNecikgrTdtrwX7zhGPm8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 160189860194889.75837415595095; Mon, 5 Oct 2020 04:50:01 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-331-5yr1qUHzMv6KAc4D4h91DA-1; Mon, 05 Oct 2020 07:49:58 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9912C10866B0; Mon, 5 Oct 2020 11:49:50 +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 772365D9E4; Mon, 5 Oct 2020 11:49:50 +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 44ADF181A87F; Mon, 5 Oct 2020 11:49:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 095BnhPl028084 for ; Mon, 5 Oct 2020 07:49:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id BCAB019C4F; Mon, 5 Oct 2020 11:49:43 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 279ED1A8EC for ; Mon, 5 Oct 2020 11:49:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601898600; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=zw2pe5cAJ6JzWK0eZkSCfhchxuorlCxAb47L4QOmOrA=; b=OxYuxRh4orzvQ3NVrzFK7bNTm8La1mHCL/m5tdRFb2zUqm/8rKIf9ginv3PlftS+H63JsV nfGDoVmmqE7NNvtnwdoGkXkTgq2mRripeUrGAjZzCxK7X4jdvApsC9nOR1euuos0aBYUoI lyBkE958E4VywvbfbZt2G+gA0b3DBak= X-MC-Unique: 5yr1qUHzMv6KAc4D4h91DA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 5/7] virbitmaptest: Refactor checks in 'test6' Date: Mon, 5 Oct 2020 13:49:27 +0200 Message-Id: <2085584d37812618e6c0abd03fc108e879f3c456.1601898456.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The 'checkBitmap' helper uses 'virBitmapFormat' internally and also reports better errors. Use it instead of the open-coded checks. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virbitmaptest.c | 44 ++++++------------------------------------- 1 file changed, 6 insertions(+), 38 deletions(-) diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c index c16be62e23..c59eb49265 100644 --- a/tests/virbitmaptest.c +++ b/tests/virbitmaptest.c @@ -407,7 +407,6 @@ static int test6(const void *v G_GNUC_UNUSED) { virBitmapPtr bitmap =3D NULL; - char *str =3D NULL; int size =3D 64; int ret =3D -1; @@ -415,73 +414,42 @@ test6(const void *v G_GNUC_UNUSED) if (!bitmap) goto error; - str =3D virBitmapFormat(bitmap); - if (!str) + if (checkBitmap(bitmap, "", -1) < 0) goto error; - if (STRNEQ(str, "")) - goto error; - - VIR_FREE(str); - ignore_value(virBitmapSetBit(bitmap, 0)); - str =3D virBitmapFormat(bitmap); - if (!str) - goto error; - if (STRNEQ(str, "0")) + if (checkBitmap(bitmap, "0", -1) < 0) goto error; - VIR_FREE(str); - ignore_value(virBitmapSetBit(bitmap, 4)); ignore_value(virBitmapSetBit(bitmap, 5)); - str =3D virBitmapFormat(bitmap); - if (!str) - goto error; - if (STRNEQ(str, "0,4-5")) + if (checkBitmap(bitmap, "0,4-5", -1) < 0) goto error; - VIR_FREE(str); - ignore_value(virBitmapSetBit(bitmap, 6)); - str =3D virBitmapFormat(bitmap); - if (!str) - goto error; - if (STRNEQ(str, "0,4-6")) + if (checkBitmap(bitmap, "0,4-6", -1) < 0) goto error; - VIR_FREE(str); - ignore_value(virBitmapSetBit(bitmap, 13)); ignore_value(virBitmapSetBit(bitmap, 14)); ignore_value(virBitmapSetBit(bitmap, 15)); ignore_value(virBitmapSetBit(bitmap, 16)); - str =3D virBitmapFormat(bitmap); - if (!str) - goto error; - if (STRNEQ(str, "0,4-6,13-16")) + if (checkBitmap(bitmap, "0,4-6,13-16", -1) < 0) goto error; - VIR_FREE(str); - ignore_value(virBitmapSetBit(bitmap, 62)); ignore_value(virBitmapSetBit(bitmap, 63)); - str =3D virBitmapFormat(bitmap); - if (!str) - goto error; - if (STRNEQ(str, "0,4-6,13-16,62-63")) + if (checkBitmap(bitmap, "0,4-6,13-16,62-63", -1) < 0) goto error; - ret =3D 0; error: virBitmapFree(bitmap); - VIR_FREE(str); return ret; } --=20 2.26.2 From nobody Mon May 6 11:33:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601898669; cv=none; d=zohomail.com; s=zohoarc; b=UJo8y2Qu6dwY0SbRSFrgWuwGohtV+XW+1RADGJqghjGlsqYkRlEIKQAbfmWyFhp+3YVwzPvOJzQa40W0e2Cw3/9O9XlODbxTV1OgQOWRD73Jjpo540ba/BYsiaTczE3CbK0Ie9p4rJ/rD8T+C9zT8MfYkdAkXmxEf046QbULMvM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601898669; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8LqwzF6stWPHyc+tzZlq2w+UFJNNLPKeNlW45kZ5u7g=; b=LsFHHuES5/CGn6L007N/vabmC6A5EqjmXcW0CaaDUkbX1fdxJmNKKjgi5mwDENE3mjlqv45GI2AyleylgfwXDc7ycD/jETflX2WBNjmDaOzTWmmPoKnPGPCMD51PYHcbNEANvCYJZ8WL+1Vk0nG9TCNipcU8nhmAOkPXMMmodgE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1601898669936496.0756884252793; Mon, 5 Oct 2020 04:51:09 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-512-8g3lilOZMsmsF1No6EDm7w-1; Mon, 05 Oct 2020 07:49:58 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2E64518A8220; Mon, 5 Oct 2020 11:49:53 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0A2CC1002C12; Mon, 5 Oct 2020 11:49:53 +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 CA9B044A68; Mon, 5 Oct 2020 11:49:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 095BniMI028094 for ; Mon, 5 Oct 2020 07:49:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id C3F3926344; Mon, 5 Oct 2020 11:49:44 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A7EE19C4F for ; Mon, 5 Oct 2020 11:49:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601898668; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=8LqwzF6stWPHyc+tzZlq2w+UFJNNLPKeNlW45kZ5u7g=; b=PPzlgQeyKXvnGeA1FOuxFlE7dUbyvK1o04Mkjqo1zkvrasONp51OLLaNorQCe40nzxSltc MjKGNQandBdEYD5xXyuv7R1YpVsntdlupq7XIm1MYnwUZmsPN5ifFpp1FuAF3BQZ9rdd5o baTf2qSdl/fr6CIDkZFWvboOyhveQTI= X-MC-Unique: 8g3lilOZMsmsF1No6EDm7w-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 6/7] virbitmaptest: Use g_auto(free) for cleanup Date: Mon, 5 Oct 2020 13:49:28 +0200 Message-Id: <3b93a1c053f495e8229ac31fba675587d0dd24e8.1601898456.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virbitmaptest.c | 79 ++++++++++++++----------------------------- 1 file changed, 25 insertions(+), 54 deletions(-) diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c index c59eb49265..fd49ed4c55 100644 --- a/tests/virbitmaptest.c +++ b/tests/virbitmaptest.c @@ -54,7 +54,7 @@ checkBitmap(virBitmapPtr map, static int test1(const void *data G_GNUC_UNUSED) { - virBitmapPtr bitmap; + g_autoptr(virBitmap) bitmap =3D NULL; int size; int bit; bool result; @@ -83,7 +83,6 @@ test1(const void *data G_GNUC_UNUSED) ret =3D 0; error: - virBitmapFree(bitmap); return ret; } @@ -110,8 +109,8 @@ static int test2(const void *data G_GNUC_UNUSED) { const char *bitsString1 =3D "1-32,50,88-99,1021-1023"; - char *bitsString2 =3D NULL; - virBitmapPtr bitmap =3D NULL; + g_autofree char *bitsString2 =3D NULL; + g_autoptr(virBitmap) bitmap =3D NULL; int ret =3D -1; int size =3D 1025; @@ -164,15 +163,13 @@ test2(const void *data G_GNUC_UNUSED) ret =3D 0; error: - virBitmapFree(bitmap); - VIR_FREE(bitsString2); return ret; } static int test3(const void *data G_GNUC_UNUSED) { - virBitmapPtr bitmap =3D NULL; + g_autoptr(virBitmap) bitmap =3D NULL; int ret =3D -1; int size =3D 5; size_t i; @@ -192,7 +189,6 @@ test3(const void *data G_GNUC_UNUSED) ret =3D 0; error: - virBitmapFree(bitmap); return ret; } @@ -200,7 +196,7 @@ test3(const void *data G_GNUC_UNUSED) static int test4a(const void *data G_GNUC_UNUSED) { - virBitmapPtr bitmap =3D NULL; + g_autoptr(virBitmap) bitmap =3D NULL; /* 0. empty set */ @@ -215,11 +211,9 @@ test4a(const void *data G_GNUC_UNUSED) if (virBitmapNextClearBit(bitmap, -1) !=3D -1) goto error; - virBitmapFree(bitmap); return 0; error: - virBitmapFree(bitmap); return -1; } @@ -227,7 +221,7 @@ test4a(const void *data G_GNUC_UNUSED) static int test4b(const void *data G_GNUC_UNUSED) { - virBitmapPtr bitmap =3D NULL; + g_autoptr(virBitmap) bitmap =3D NULL; int size =3D 40; size_t i; @@ -253,11 +247,9 @@ test4b(const void *data G_GNUC_UNUSED) if (!virBitmapIsAllClear(bitmap)) goto error; - virBitmapFree(bitmap); return 0; error: - virBitmapFree(bitmap); return -1; } @@ -275,7 +267,7 @@ test4c(const void *data G_GNUC_UNUSED) 1, 5, 11, 13, 19, 21, 23, 24, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39 }; - virBitmapPtr bitmap =3D NULL; + g_autoptr(virBitmap) bitmap =3D NULL; ssize_t i, j; if (G_N_ELEMENTS(bitsPos) + G_N_ELEMENTS(bitsPosInv) !=3D size) @@ -334,11 +326,9 @@ test4c(const void *data G_GNUC_UNUSED) if (virBitmapNextClearBit(bitmap, -1) !=3D -1) goto error; - virBitmapFree(bitmap); return 0; error: - virBitmapFree(bitmap); return -1; } @@ -347,10 +337,10 @@ static int test5(const void *v G_GNUC_UNUSED) { char data[] =3D {0x01, 0x02, 0x00, 0x00, 0x04}; - unsigned char *data2 =3D NULL; + g_autofree unsigned char *data2 =3D NULL; int len2; int bits[] =3D {0, 9, 34}; - virBitmapPtr bitmap; + g_autoptr(virBitmap) bitmap =3D NULL; size_t i; ssize_t j; int ret =3D -1; @@ -396,8 +386,6 @@ test5(const void *v G_GNUC_UNUSED) ret =3D 0; error: - virBitmapFree(bitmap); - VIR_FREE(data2); return ret; } @@ -406,7 +394,7 @@ test5(const void *v G_GNUC_UNUSED) static int test6(const void *v G_GNUC_UNUSED) { - virBitmapPtr bitmap =3D NULL; + g_autoptr(virBitmap) bitmap =3D NULL; int size =3D 64; int ret =3D -1; @@ -449,14 +437,12 @@ test6(const void *v G_GNUC_UNUSED) ret =3D 0; error: - virBitmapFree(bitmap); return ret; } static int test7(const void *v G_GNUC_UNUSED) { - virBitmapPtr bitmap; size_t i; size_t maxBit[] =3D { 1, 8, 31, 32, 63, 64, 95, 96, 127, 128, 159, 160 @@ -464,7 +450,7 @@ test7(const void *v G_GNUC_UNUSED) size_t nmaxBit =3D 12; for (i =3D 0; i < nmaxBit; i++) { - bitmap =3D virBitmapNew(maxBit[i]); + g_autoptr(virBitmap) bitmap =3D virBitmapNew(maxBit[i]); if (!bitmap) goto error; @@ -482,21 +468,18 @@ test7(const void *v G_GNUC_UNUSED) virBitmapClearAll(bitmap); if (!virBitmapIsAllClear(bitmap)) goto error; - - virBitmapFree(bitmap); } return 0; error: - virBitmapFree(bitmap); return -1; } static int test8(const void *v G_GNUC_UNUSED) { - virBitmapPtr bitmap =3D NULL; + g_autoptr(virBitmap) bitmap =3D NULL; char data[108] =3D {0x00,}; int ret =3D -1; @@ -515,7 +498,6 @@ test8(const void *v G_GNUC_UNUSED) ret =3D 0; cleanup: - virBitmapFree(bitmap); return ret; } @@ -525,7 +507,7 @@ static int test9(const void *opaque G_GNUC_UNUSED) { int ret =3D -1; - virBitmapPtr bitmap =3D NULL; + g_autoptr(virBitmap) bitmap =3D NULL; if (virBitmapParse("100000000", &bitmap, 20) !=3D -1) goto cleanup; @@ -547,7 +529,6 @@ test9(const void *opaque G_GNUC_UNUSED) ret =3D 0; cleanup: - virBitmapFree(bitmap); return ret; } @@ -556,7 +537,10 @@ static int test10(const void *opaque G_GNUC_UNUSED) { int ret =3D -1; - virBitmapPtr b1 =3D NULL, b2 =3D NULL, b3 =3D NULL, b4 =3D NULL; + g_autoptr(virBitmap) b1 =3D NULL; + g_autoptr(virBitmap) b2 =3D NULL; + g_autoptr(virBitmap) b3 =3D NULL; + g_autoptr(virBitmap) b4 =3D NULL; if (virBitmapParseSeparator("0-3,5-8,11-15f16", 'f', &b1, 20) < 0 || virBitmapParse("4,9,10,16-19", &b2, 20) < 0 || @@ -577,10 +561,6 @@ test10(const void *opaque G_GNUC_UNUSED) ret =3D 0; cleanup: - virBitmapFree(b1); - virBitmapFree(b2); - virBitmapFree(b3); - virBitmapFree(b4); return ret; } @@ -594,9 +574,9 @@ static int test11(const void *opaque) { const struct testBinaryOpData *data =3D opaque; - virBitmapPtr amap =3D NULL; - virBitmapPtr bmap =3D NULL; - virBitmapPtr resmap =3D NULL; + g_autoptr(virBitmap) amap =3D NULL; + g_autoptr(virBitmap) bmap =3D NULL; + g_autoptr(virBitmap) resmap =3D NULL; int ret =3D -1; if (virBitmapParse(data->a, &amap, 256) < 0 || @@ -616,10 +596,6 @@ test11(const void *opaque) ret =3D 0; cleanup: - virBitmapFree(amap); - virBitmapFree(bmap); - virBitmapFree(resmap); - return ret; } @@ -628,7 +604,7 @@ test11(const void *opaque) static int test12a(const void *opaque G_GNUC_UNUSED) { - virBitmapPtr map =3D virBitmapNewEmpty(); + g_autoptr(virBitmap) map =3D virBitmapNewEmpty(); int ret =3D -1; if (checkBitmap(map, "", 0) < 0) @@ -649,7 +625,6 @@ test12a(const void *opaque G_GNUC_UNUSED) ret =3D 0; cleanup: - virBitmapFree(map); return ret; } @@ -657,7 +632,7 @@ test12a(const void *opaque G_GNUC_UNUSED) static int test12b(const void *opaque G_GNUC_UNUSED) { - virBitmapPtr map =3D virBitmapNewEmpty(); + g_autoptr(virBitmap) map =3D NULL; int ret =3D -1; if (!(map =3D virBitmapParseUnlimited("34,1023"))) @@ -677,7 +652,6 @@ test12b(const void *opaque G_GNUC_UNUSED) ret =3D 0; cleanup: - virBitmapFree(map); return ret; } @@ -714,9 +688,9 @@ static int test14(const void *opaque) { const struct testBinaryOpData *data =3D opaque; - virBitmapPtr amap =3D NULL; - virBitmapPtr bmap =3D NULL; - virBitmapPtr resmap =3D NULL; + g_autoptr(virBitmap) amap =3D NULL; + g_autoptr(virBitmap) bmap =3D NULL; + g_autoptr(virBitmap) resmap =3D NULL; int ret =3D -1; if (virBitmapParse(data->a, &amap, 256) < 0 || @@ -736,9 +710,6 @@ test14(const void *opaque) ret =3D 0; cleanup: - virBitmapFree(amap); - virBitmapFree(bmap); - virBitmapFree(resmap); return ret; } --=20 2.26.2 From nobody Mon May 6 11:33:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601898601; cv=none; d=zohomail.com; s=zohoarc; b=TMYWyWNse4XbB0WfmBdq6Fwg5BOwZ3OE0u8tp0K7WYdOi9M58Z9Y9gSsnSiGSazXzZFuWKSbARhpAKvuB3Lj8Uw3knue9MdSrbIma8ZQxv33V6CmtxZkHywpIhNJGhdZvTgpLO5ZAzZwZGLXSP3FGnh0g6LsncpETfwsqryx7Uo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601898601; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3Kv/k8uE7e6sY/XmlPXcWl4kFgNF4Cw25POwYa6LsQY=; b=G7vwQuWkTGKOa60FKtte/b05zXsSLaNfkFNHiPm1jRZXXSto8TszQL3jPLJBXFBUFd8A8DcUfvGuh/E5BMDwxPTU0/wGAww+cRaHCWQf7O6YPGCsSpuZLVy2yf3fjJ1KenO4LPuzGZGgOabB8fF5GOvGTBuZdrN/zuA/Am7djDg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1601898601524155.27134785695932; Mon, 5 Oct 2020 04:50:01 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-398--iQKzqL1PsaaqcaF5HC0NQ-1; Mon, 05 Oct 2020 07:49:57 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B858E8030AE; Mon, 5 Oct 2020 11:49:49 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 96F2B60C05; Mon, 5 Oct 2020 11:49: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 38AE244A63; Mon, 5 Oct 2020 11:49:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 095Bnkxh028115 for ; Mon, 5 Oct 2020 07:49:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0EA0219C4F; Mon, 5 Oct 2020 11:49:46 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 413281A8EC for ; Mon, 5 Oct 2020 11:49:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601898600; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=3Kv/k8uE7e6sY/XmlPXcWl4kFgNF4Cw25POwYa6LsQY=; b=WDeGxOVytdzCUA9ld6w1sejqaJEbSE/44l0c3dHdnUiArXy2uG0DBSMLBycSs0SlArEwEk ldsV2pTb4mpwOc+ap2whrWgA5VbtlxOEjFsvoQXA/vhKCSUeN0BAeyYKmaAWxn02KHN5C3 R5eB+AGLrDGqJpm6hRh0DkT6GMzBn50= X-MC-Unique: -iQKzqL1PsaaqcaF5HC0NQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 7/7] virbitmaptest: Remove unnecessary error/cleanup labels Date: Mon, 5 Oct 2020 13:49:29 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virbitmaptest.c | 270 +++++++++++++++++------------------------- 1 file changed, 107 insertions(+), 163 deletions(-) diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c index fd49ed4c55..3559e61be7 100644 --- a/tests/virbitmaptest.c +++ b/tests/virbitmaptest.c @@ -58,32 +58,28 @@ test1(const void *data G_GNUC_UNUSED) int size; int bit; bool result; - int ret =3D -1; size =3D 1024; bit =3D 100; if (!(bitmap =3D virBitmapNew(size))) - goto error; + return -1; if (virBitmapSetBit(bitmap, bit) < 0) - goto error; + return -1; if (virBitmapGetBit(bitmap, bit, &result) < 0) - goto error; + return -1; if (!result) - goto error; + return -1; if (virBitmapGetBit(bitmap, bit + 1, &result) < 0) - goto error; + return -1; if (result) - goto error; - - ret =3D 0; + return -1; - error: - return ret; + return 0; } static int @@ -111,85 +107,78 @@ test2(const void *data G_GNUC_UNUSED) const char *bitsString1 =3D "1-32,50,88-99,1021-1023"; g_autofree char *bitsString2 =3D NULL; g_autoptr(virBitmap) bitmap =3D NULL; - int ret =3D -1; int size =3D 1025; if (virBitmapParse(bitsString1, &bitmap, size) < 0) - goto error; + return -1; if (testBit(bitmap, 1, 32, true) < 0) - goto error; + return -1; if (testBit(bitmap, 50, 50, true) < 0) - goto error; + return -1; if (testBit(bitmap, 88, 99, true) < 0) - goto error; + return -1; if (testBit(bitmap, 1021, 1023, true) < 0) - goto error; + return -1; if (testBit(bitmap, 0, 0, false) < 0) - goto error; + return -1; if (testBit(bitmap, 33, 49, false) < 0) - goto error; + return -1; if (testBit(bitmap, 51, 87, false) < 0) - goto error; + return -1; if (testBit(bitmap, 100, 1020, false) < 0) - goto error; + return -1; if (virBitmapCountBits(bitmap) !=3D 48) - goto error; + return -1; if (!(bitsString2 =3D virBitmapFormat(bitmap))) - goto error; + return -1; if (strcmp(bitsString1, bitsString2)) - goto error; + return -1; virBitmapSetAll(bitmap); if (testBit(bitmap, 0, size - 1, true) < 0) - goto error; + return -1; if (virBitmapCountBits(bitmap) !=3D size) - goto error; + return -1; if (!virBitmapIsAllSet(bitmap)) - goto error; + return -1; virBitmapClearAll(bitmap); if (!virBitmapIsAllClear(bitmap)) - goto error; + return -1; if (testBit(bitmap, 0, size - 1, false) < 0) - goto error; + return -1; if (virBitmapCountBits(bitmap) !=3D 0) - goto error; - - ret =3D 0; + return -1; - error: - return ret; + return 0; } static int test3(const void *data G_GNUC_UNUSED) { g_autoptr(virBitmap) bitmap =3D NULL; - int ret =3D -1; int size =3D 5; size_t i; if ((bitmap =3D virBitmapNew(size)) =3D=3D NULL) - goto error; + return -1; for (i =3D 0; i < size; i++) ignore_value(virBitmapSetBit(bitmap, i)); if (!virBitmapIsAllSet(bitmap)) - goto error; + return -1; virBitmapClearAll(bitmap); if (!virBitmapIsAllClear(bitmap)) - goto error; - ret =3D 0; + return -1; - error: - return ret; + return 0; } /* test for virBitmapNextSetBit, virBitmapLastSetBit, virBitmapNextClearBi= t */ @@ -203,18 +192,15 @@ test4a(const void *data G_GNUC_UNUSED) bitmap =3D virBitmapNewEmpty(); if (virBitmapNextSetBit(bitmap, -1) !=3D -1) - goto error; + return -1; if (virBitmapLastSetBit(bitmap) !=3D -1) - goto error; + return -1; if (virBitmapNextClearBit(bitmap, -1) !=3D -1) - goto error; + return -1; return 0; - - error: - return -1; } @@ -229,28 +215,25 @@ test4b(const void *data G_GNUC_UNUSED) bitmap =3D virBitmapNew(size); if (!bitmap) - goto error; + return -1; if (virBitmapNextSetBit(bitmap, -1) !=3D -1) - goto error; + return -1; if (virBitmapLastSetBit(bitmap) !=3D -1) - goto error; + return -1; for (i =3D 0; i < size; i++) { if (virBitmapNextClearBit(bitmap, i - 1) !=3D i) - goto error; + return -1; } if (virBitmapNextClearBit(bitmap, i) !=3D -1) - goto error; + return -1; if (!virBitmapIsAllClear(bitmap)) - goto error; + return -1; return 0; - - error: - return -1; } @@ -271,14 +254,14 @@ test4c(const void *data G_GNUC_UNUSED) ssize_t i, j; if (G_N_ELEMENTS(bitsPos) + G_N_ELEMENTS(bitsPosInv) !=3D size) - goto error; + return -1; /* 2. partial set */ if (virBitmapParse(bitsString, &bitmap, size) < 0) - goto error; + return -1; if (!bitmap) - goto error; + return -1; j =3D 0; i =3D -1; @@ -286,16 +269,16 @@ test4c(const void *data G_GNUC_UNUSED) while (j < G_N_ELEMENTS(bitsPos)) { i =3D virBitmapNextSetBit(bitmap, i); if (i !=3D bitsPos[j++]) - goto error; + return -1; } if (virBitmapNextSetBit(bitmap, i) !=3D -1) - goto error; + return -1; j =3D sizeof(bitsPos)/sizeof(int) - 1; if (virBitmapLastSetBit(bitmap) !=3D bitsPos[j]) - goto error; + return -1; j =3D 0; i =3D -1; @@ -303,11 +286,11 @@ test4c(const void *data G_GNUC_UNUSED) while (j < G_N_ELEMENTS(bitsPosInv)) { i =3D virBitmapNextClearBit(bitmap, i); if (i !=3D bitsPosInv[j++]) - goto error; + return -1; } if (virBitmapNextClearBit(bitmap, i) !=3D -1) - goto error; + return -1; /* 3. full set */ @@ -315,21 +298,18 @@ test4c(const void *data G_GNUC_UNUSED) for (i =3D 0; i < size; i++) { if (virBitmapNextSetBit(bitmap, i - 1) !=3D i) - goto error; + return -1; } if (virBitmapNextSetBit(bitmap, i) !=3D -1) - goto error; + return -1; if (virBitmapLastSetBit(bitmap) !=3D size - 1) - goto error; + return -1; if (virBitmapNextClearBit(bitmap, -1) !=3D -1) - goto error; + return -1; return 0; - - error: - return -1; } /* test for virBitmapNewData/ToData/DataFormat */ @@ -343,29 +323,28 @@ test5(const void *v G_GNUC_UNUSED) g_autoptr(virBitmap) bitmap =3D NULL; size_t i; ssize_t j; - int ret =3D -1; g_autofree char *actual1 =3D NULL; g_autofree char *actual2 =3D NULL; bitmap =3D virBitmapNewData(data, sizeof(data)); if (!bitmap) - goto error; + return -1; i =3D 0; j =3D -1; while (i < sizeof(bits)/sizeof(int) && (j =3D virBitmapNextSetBit(bitmap, j)) >=3D 0) { if (j !=3D bits[i++]) - goto error; + return -1; } if (virBitmapNextSetBit(bitmap, j) > 0) - goto error; + return -1; ignore_value(virBitmapSetBit(bitmap, 2)); ignore_value(virBitmapSetBit(bitmap, 15)); if (virBitmapToData(bitmap, &data2, &len2) < 0) - goto error; + return -1; if (len2 !=3D sizeof(data) || data2[0] !=3D 0x05 || @@ -373,20 +352,18 @@ test5(const void *v G_GNUC_UNUSED) data2[2] !=3D 0x00 || data2[3] !=3D 0x00 || data2[4] !=3D 0x04) - goto error; + return -1; if (!(actual1 =3D virBitmapDataFormat(data, sizeof(data)))) - goto error; + return -1; if (STRNEQ(actual1, "0,9,34")) - goto error; + return -1; if (!(actual2 =3D virBitmapDataFormat(data2, len2))) - goto error; + return -1; if (STRNEQ(actual2, "0,2,9,15,34")) - goto error; + return -1; - ret =3D 0; - error: - return ret; + return 0; } @@ -396,30 +373,29 @@ test6(const void *v G_GNUC_UNUSED) { g_autoptr(virBitmap) bitmap =3D NULL; int size =3D 64; - int ret =3D -1; bitmap =3D virBitmapNew(size); if (!bitmap) - goto error; + return -1; if (checkBitmap(bitmap, "", -1) < 0) - goto error; + return -1; ignore_value(virBitmapSetBit(bitmap, 0)); if (checkBitmap(bitmap, "0", -1) < 0) - goto error; + return -1; ignore_value(virBitmapSetBit(bitmap, 4)); ignore_value(virBitmapSetBit(bitmap, 5)); if (checkBitmap(bitmap, "0,4-5", -1) < 0) - goto error; + return -1; ignore_value(virBitmapSetBit(bitmap, 6)); if (checkBitmap(bitmap, "0,4-6", -1) < 0) - goto error; + return -1; ignore_value(virBitmapSetBit(bitmap, 13)); ignore_value(virBitmapSetBit(bitmap, 14)); @@ -427,17 +403,15 @@ test6(const void *v G_GNUC_UNUSED) ignore_value(virBitmapSetBit(bitmap, 16)); if (checkBitmap(bitmap, "0,4-6,13-16", -1) < 0) - goto error; + return -1; ignore_value(virBitmapSetBit(bitmap, 62)); ignore_value(virBitmapSetBit(bitmap, 63)); if (checkBitmap(bitmap, "0,4-6,13-16,62-63", -1) < 0) - goto error; + return -1; - ret =3D 0; - error: - return ret; + return 0; } static int @@ -452,28 +426,25 @@ test7(const void *v G_GNUC_UNUSED) for (i =3D 0; i < nmaxBit; i++) { g_autoptr(virBitmap) bitmap =3D virBitmapNew(maxBit[i]); if (!bitmap) - goto error; + return -1; if (virBitmapIsAllSet(bitmap)) - goto error; + return -1; ignore_value(virBitmapSetBit(bitmap, 1)); if (virBitmapIsAllSet(bitmap)) - goto error; + return -1; virBitmapSetAll(bitmap); if (!virBitmapIsAllSet(bitmap)) - goto error; + return -1; virBitmapClearAll(bitmap); if (!virBitmapIsAllClear(bitmap)) - goto error; + return -1; } return 0; - - error: - return -1; } static int @@ -481,24 +452,21 @@ test8(const void *v G_GNUC_UNUSED) { g_autoptr(virBitmap) bitmap =3D NULL; char data[108] =3D {0x00,}; - int ret =3D -1; bitmap =3D virBitmapNewData(data, sizeof(data)); if (!bitmap) - goto cleanup; + return -1; if (!virBitmapIsAllClear(bitmap)) - goto cleanup; + return -1; if (virBitmapSetBit(bitmap, 11) < 0) - goto cleanup; + return -1; if (virBitmapIsAllClear(bitmap)) - goto cleanup; + return -1; - ret =3D 0; - cleanup: - return ret; + return 0; } @@ -506,37 +474,32 @@ test8(const void *v G_GNUC_UNUSED) static int test9(const void *opaque G_GNUC_UNUSED) { - int ret =3D -1; g_autoptr(virBitmap) bitmap =3D NULL; if (virBitmapParse("100000000", &bitmap, 20) !=3D -1) - goto cleanup; + return -1; if (bitmap) - goto cleanup; + return -1; if (virBitmapParse("1-1000000000", &bitmap, 20) !=3D -1) - goto cleanup; + return -1; if (bitmap) - goto cleanup; + return -1; if (virBitmapParse("1-10^10000000000", &bitmap, 20) !=3D -1) - goto cleanup; + return -1; if (bitmap) - goto cleanup; - - ret =3D 0; - cleanup: - return ret; + return -1; + return 0; } static int test10(const void *opaque G_GNUC_UNUSED) { - int ret =3D -1; g_autoptr(virBitmap) b1 =3D NULL; g_autoptr(virBitmap) b2 =3D NULL; g_autoptr(virBitmap) b3 =3D NULL; @@ -546,10 +509,10 @@ test10(const void *opaque G_GNUC_UNUSED) virBitmapParse("4,9,10,16-19", &b2, 20) < 0 || virBitmapParse("15", &b3, 20) < 0 || virBitmapParse("0,^0", &b4, 20) < 0) - goto cleanup; + return -1; if (!virBitmapIsAllClear(b4)) - goto cleanup; + return -1; if (virBitmapOverlaps(b1, b2) || virBitmapOverlaps(b1, b4) || @@ -557,11 +520,9 @@ test10(const void *opaque G_GNUC_UNUSED) virBitmapOverlaps(b2, b4) || !virBitmapOverlaps(b1, b3) || virBitmapOverlaps(b3, b4)) - goto cleanup; + return -1; - ret =3D 0; - cleanup: - return ret; + return 0; } struct testBinaryOpData { @@ -577,12 +538,11 @@ test11(const void *opaque) g_autoptr(virBitmap) amap =3D NULL; g_autoptr(virBitmap) bmap =3D NULL; g_autoptr(virBitmap) resmap =3D NULL; - int ret =3D -1; if (virBitmapParse(data->a, &amap, 256) < 0 || virBitmapParse(data->b, &bmap, 256) < 0 || virBitmapParse(data->res, &resmap, 256) < 0) - goto cleanup; + return -1; virBitmapIntersect(amap, bmap); @@ -590,13 +550,10 @@ test11(const void *opaque) fprintf(stderr, "\n bitmap intersection failed: intersect('%s','%s') !=3D'= %s'\n", data->a, data->b, data->res); - goto cleanup; + return -1; } - ret =3D 0; - - cleanup: - return ret; + return 0; } @@ -605,27 +562,23 @@ static int test12a(const void *opaque G_GNUC_UNUSED) { g_autoptr(virBitmap) map =3D virBitmapNewEmpty(); - int ret =3D -1; if (checkBitmap(map, "", 0) < 0) - goto cleanup; + return -1; if (virBitmapSetBitExpand(map, 128) < 0) - goto cleanup; + return -1; if (checkBitmap(map, "128", 129) < 0) - goto cleanup; + return -1; if (virBitmapClearBitExpand(map, 150) < 0) - goto cleanup; + return -1; if (checkBitmap(map, "128", 151) < 0) - goto cleanup; - - ret =3D 0; + return -1; - cleanup: - return ret; + return 0; } @@ -633,26 +586,22 @@ static int test12b(const void *opaque G_GNUC_UNUSED) { g_autoptr(virBitmap) map =3D NULL; - int ret =3D -1; if (!(map =3D virBitmapParseUnlimited("34,1023"))) - goto cleanup; + return -1; if (checkBitmap(map, "34,1023", 1024) < 0) - goto cleanup; + return -1; virBitmapShrink(map, 35); if (checkBitmap(map, "34", 35) < 0) - goto cleanup; + return -1; virBitmapShrink(map, 34); if (checkBitmap(map, "", 34) < 0) - goto cleanup; - - ret =3D 0; + return -1; - cleanup: - return ret; + return 0; } @@ -691,12 +640,11 @@ test14(const void *opaque) g_autoptr(virBitmap) amap =3D NULL; g_autoptr(virBitmap) bmap =3D NULL; g_autoptr(virBitmap) resmap =3D NULL; - int ret =3D -1; if (virBitmapParse(data->a, &amap, 256) < 0 || virBitmapParse(data->b, &bmap, 256) < 0 || virBitmapParse(data->res, &resmap, 256) < 0) - goto cleanup; + return -1; virBitmapSubtract(amap, bmap); @@ -704,14 +652,10 @@ test14(const void *opaque) fprintf(stderr, "\n bitmap subtraction failed: '%s' - '%s' !=3D '%s'\n", data->a, data->b, data->res); - goto cleanup; + return -1; } - ret =3D 0; - - cleanup: - - return ret; + return 0; } /* virBitmapUnion() */ --=20 2.26.2