From nobody Sun Feb 8 20:17:35 2026 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=1630788711; cv=none; d=zohomail.com; s=zohoarc; b=j+Mquy/FfOjnCeS4ul3h8QYSu2cVSBbDBKobhVAoPTxl+uEByrhbynN3wZpy+xbw2cC19V1WqYgMEbys1foZ5hpfU9tCu5g8/wzq9I9K2zoD3MS28273sBUYmD6je9NvCL9z91wxsCfaTwtasmeL2S6reiA2StV3FHgOf97L7qo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630788711; 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=l27R2vyJCC782MpuPypU2QlfNuQiNXS8eaOzBg+hZO8=; b=Z/Il80MBiYlnM3q6ZRAXH/ZaaLBi11v01MiGN15nmP6i3xo/002Z58J54Xe6kKr7k7CIpS0V75MXq4xdvj47o0OZQny8ZiRPhY5krPwwvWO+JT+HK9LRLB1x8hVuKII48SulfMsui3YXrhGwYmObMFReUaNCZPKXcHF66BZgVfA= 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) 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 1630788711014339.0622909011985; Sat, 4 Sep 2021 13:51:51 -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-203-C4CBRr3hNUqOXyNWp1h83Q-1; Sat, 04 Sep 2021 16:51:48 -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 85E09107ACE4; Sat, 4 Sep 2021 20:51:43 +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 4AE7760C9D; Sat, 4 Sep 2021 20:51:43 +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 1E1CF44A5F; Sat, 4 Sep 2021 20:51:43 +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 184KiqPj008946 for ; Sat, 4 Sep 2021 16:44:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3E5CC2619D; Sat, 4 Sep 2021 20:44:52 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id B9D3A1F4 for ; Sat, 4 Sep 2021 20:44:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630788710; 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=l27R2vyJCC782MpuPypU2QlfNuQiNXS8eaOzBg+hZO8=; b=IPzLO4njmx1G3ZRez4A7u6W5W/hs3N8pR0moJk1Nm0Y19ZIy+4H1I51rfQgFOGmFsqeSaS JJ7AK+MU6aoxKvlRJLh8I2xkiGhvsLDeXlzYiW/iAbx3aLGgXgBT320VHoKKJ2moIOUHrH pn3AaxSz3qSl/wncgYwmFjVkqliPFGE= X-MC-Unique: C4CBRr3hNUqOXyNWp1h83Q-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 24/24] tests: remove pointless labels Date: Sat, 4 Sep 2021 22:44:22 +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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1630788711618100001 Signed-off-by: J=C3=A1n Tomko --- tests/cputest.c | 42 ++++++++++++-------------------- tests/domaincapstest.c | 39 ++++++++++++----------------- tests/domainconftest.c | 12 +++------ tests/fchosttest.c | 40 +++++++++++------------------- tests/lxcconf2xmltest.c | 16 +++++------- tests/metadatatest.c | 28 +++++++-------------- tests/openvzutilstest.c | 11 +++------ tests/scsihosttest.c | 22 +++++++---------- tests/securityselinuxlabeltest.c | 12 +++------ tests/vmwarevertest.c | 14 ++++------- 10 files changed, 84 insertions(+), 152 deletions(-) diff --git a/tests/cputest.c b/tests/cputest.c index 11305d56c5..0f0621292a 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -520,7 +520,6 @@ static int cpuTestCPUID(bool guest, const void *arg) { const struct data *data =3D arg; - int ret =3D -1; g_autoptr(virCPUData) hostData =3D NULL; g_autofree char *hostFile =3D NULL; g_autofree char *host =3D NULL; @@ -533,7 +532,7 @@ cpuTestCPUID(bool guest, const void *arg) =20 if (virTestLoadFile(hostFile, &host) < 0 || !(hostData =3D virCPUDataParse(host))) - goto cleanup; + return -1; =20 cpu =3D virCPUDefNew(); cpu->arch =3D hostData->arch; @@ -549,21 +548,16 @@ cpuTestCPUID(bool guest, const void *arg) int rc; =20 rc =3D cpuTestGetCPUModels(data, &models); - if (rc !=3D 0) { - ret =3D rc; - goto cleanup; - } + if (rc !=3D 0) + return rc; } =20 if (cpuDecode(cpu, hostData, models) < 0) - goto cleanup; + return -1; =20 result =3D g_strdup_printf("cpuid-%s-%s", data->host, guest ? "guest" = : "host"); =20 - ret =3D cpuTestCompareXML(data->arch, cpu, result); - - cleanup: - return ret; + return cpuTestCompareXML(data->arch, cpu, result); } =20 =20 @@ -729,27 +723,26 @@ cpuTestUpdateLive(const void *arg) g_autoptr(virCPUDef) expected =3D NULL; g_autoptr(virDomainCapsCPUModels) hvModels =3D NULL; g_autoptr(virDomainCapsCPUModels) models =3D NULL; - int ret =3D -1; =20 cpuFile =3D g_strdup_printf("cpuid-%s-guest", data->host); if (!(cpu =3D cpuTestLoadXML(data->arch, cpuFile))) - goto cleanup; + return -1; =20 enabledFile =3D g_strdup_printf("%s/cputestdata/%s-cpuid-%s-enabled.xm= l", abs_srcdir, virArchToString(data->arch),= data->host); if (virTestLoadFile(enabledFile, &enabled) < 0 || !(enabledData =3D virCPUDataParse(enabled))) - goto cleanup; + return -1; =20 disabledFile =3D g_strdup_printf("%s/cputestdata/%s-cpuid-%s-disabled.= xml", abs_srcdir, virArchToString(data->arch)= , data->host); if (virTestLoadFile(disabledFile, &disabled) < 0 || !(disabledData =3D virCPUDataParse(disabled))) - goto cleanup; + return -1; =20 expectedFile =3D g_strdup_printf("cpuid-%s-json", data->host); if (!(expected =3D cpuTestLoadXML(data->arch, expectedFile))) - goto cleanup; + return -1; =20 /* In case the host CPU signature does not exactly match any CPU model= in * src/cpu_map, the CPU model we detect from CPUID may differ from the= one @@ -764,13 +757,11 @@ cpuTestUpdateLive(const void *arg) int rc; =20 if (!(models =3D virDomainCapsCPUModelsNew(0))) - goto cleanup; + return -1; =20 rc =3D cpuTestGetCPUModels(data, &hvModels); - if (rc !=3D 0) { - ret =3D rc; - goto cleanup; - } + if (rc !=3D 0) + return rc; =20 hvModel =3D virDomainCapsCPUModelsGet(hvModels, expected->model); =20 @@ -781,7 +772,7 @@ cpuTestUpdateLive(const void *arg) =20 if (virDomainCapsCPUModelsAdd(models, expected->model, usable, blockers, false) < 0) - goto cleanup; + return -1; =20 cpu->fallback =3D VIR_CPU_FALLBACK_ALLOW; ignore_value(virCPUTranslate(data->arch, cpu, models)); @@ -789,12 +780,9 @@ cpuTestUpdateLive(const void *arg) } =20 if (virCPUUpdateLive(data->arch, cpu, enabledData, disabledData) < 0) - goto cleanup; + return -1; =20 - ret =3D cpuTestUpdateLiveCompare(data->arch, cpu, expected); - - cleanup: - return ret; + return cpuTestUpdateLiveCompare(data->arch, cpu, expected); } =20 =20 diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index 463ff83890..9ea5bed5c2 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -73,18 +73,17 @@ fillQemuCaps(virDomainCaps *domCaps, const char *machine, virQEMUDriverConfig *cfg) { - int ret =3D -1; g_autofree char *path =3D NULL; g_autoptr(virQEMUCaps) qemuCaps =3D NULL; virDomainCapsLoader *loader =3D &domCaps->os.loader; virDomainVirtType virtType; =20 if (fakeHostCPU(domCaps->arch) < 0) - goto cleanup; + return -1; =20 path =3D g_strdup_printf("%s/%s.%s.xml", TEST_QEMU_CAPS_PATH, name, ar= ch); if (!(qemuCaps =3D qemuTestParseCapabilitiesArch(domCaps->arch, path))) - goto cleanup; + return -1; =20 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) virtType =3D VIR_DOMAIN_VIRT_KVM; @@ -103,7 +102,7 @@ fillQemuCaps(virDomainCaps *domCaps, false, cfg->firmwares, cfg->nfirmwares) < 0) - goto cleanup; + return -1; =20 /* The function above tries to query host's VFIO capabilities by calli= ng * qemuHostdevHostSupportsPassthroughVFIO() which, however, can't be @@ -123,11 +122,9 @@ fillQemuCaps(virDomainCaps *domCaps, "/usr/share/AAVMF/AAVMF32_CODE.fd", "/usr/share/OVMF/OVMF_CODE.fd", NULL) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } #endif /* WITH_QEMU */ =20 @@ -167,19 +164,16 @@ static int fillBhyveCaps(virDomainCaps *domCaps, unsigned int *bhyve_caps) { g_autofree virDomainCapsStringValues *firmwares =3D NULL; - int ret =3D -1; =20 firmwares =3D g_new0(virDomainCapsStringValues, 1); =20 if (fillStringValues(firmwares, "/foo/bar", "/foo/baz", NULL) < 0) - goto cleanup; + return -1; =20 if (virBhyveDomainCapsFill(domCaps, *bhyve_caps, firmwares) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } #endif /* WITH_BHYVE */ =20 @@ -208,14 +202,13 @@ test_virDomainCapsFormat(const void *opaque) g_autoptr(virDomainCaps) domCaps =3D NULL; g_autofree char *path =3D NULL; g_autofree char *domCapsXML =3D NULL; - int ret =3D -1; =20 path =3D g_strdup_printf("%s/domaincapsdata/%s.xml", abs_srcdir, data-= >name); =20 if (!(domCaps =3D virDomainCapsNew(data->emulator, data->machine, virArchFromString(data->arch), data->type))) - goto cleanup; + return -1; =20 switch (data->capsType) { case CAPS_NONE: @@ -225,33 +218,31 @@ test_virDomainCapsFormat(const void *opaque) #if WITH_QEMU if (fillQemuCaps(domCaps, data->capsName, data->arch, data->machin= e, data->capsOpaque) < 0) - goto cleanup; + return -1; #endif break; =20 case CAPS_LIBXL: #if WITH_LIBXL if (fillXenCaps(domCaps) < 0) - goto cleanup; + return -1; #endif break; case CAPS_BHYVE: #if WITH_BHYVE if (fillBhyveCaps(domCaps, data->capsOpaque) < 0) - goto cleanup; + return -1; #endif break; } =20 if (!(domCapsXML =3D virDomainCapsFormat(domCaps))) - goto cleanup; + return -1; =20 if (virTestCompareToFile(domCapsXML, path) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 diff --git a/tests/domainconftest.c b/tests/domainconftest.c index aaf58bcf93..71fd1f7b73 100644 --- a/tests/domainconftest.c +++ b/tests/domainconftest.c @@ -40,7 +40,6 @@ struct testGetFilesystemData { =20 static int testGetFilesystem(const void *opaque) { - int ret =3D -1; g_autoptr(virDomainDef) def =3D NULL; g_autofree char *filename =3D NULL; const struct testGetFilesystemData *data =3D opaque; @@ -50,7 +49,7 @@ static int testGetFilesystem(const void *opaque) data->filename); =20 if (!(def =3D virDomainDefParseFile(filename, xmlopt, NULL, 0))) - goto cleanup; + return -1; =20 fsdef =3D virDomainGetFilesystemForTarget(def, data->path); @@ -58,20 +57,17 @@ static int testGetFilesystem(const void *opaque) if (data->expectEntry) { fprintf(stderr, "Expected FS for path '%s' in '%s'\n", data->path, filename); - goto cleanup; + return -1; } } else { if (!data->expectEntry) { fprintf(stderr, "Unexpected FS for path '%s' in '%s'\n", data->path, filename); - goto cleanup; + return -1; } } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int diff --git a/tests/fchosttest.c b/tests/fchosttest.c index 707dd7e410..dc1503e9a7 100644 --- a/tests/fchosttest.c +++ b/tests/fchosttest.c @@ -123,7 +123,6 @@ test3(const void *data G_GNUC_UNUSED) g_autofree char *fabric_wwn =3D NULL; g_autofree char *max_vports =3D NULL; g_autofree char *vports =3D NULL; - int ret =3D -1; =20 if (!(wwnn =3D virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM, "node_name"))) @@ -131,31 +130,29 @@ test3(const void *data G_GNUC_UNUSED) =20 if (!(wwpn =3D virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM, "port_name"))) - goto cleanup; + return -1; =20 if (!(fabric_wwn =3D virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOS= T_NUM, "fabric_name"))) - goto cleanup; + return -1; =20 if (!(max_vports =3D virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOS= T_NUM, "max_npiv_vports"))) - goto cleanup; + return -1; =20 =20 if (!(vports =3D virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NU= M, "npiv_vports_inuse"))) - goto cleanup; + return -1; =20 if (STRNEQ(expect_wwnn, wwnn) || STRNEQ(expect_wwpn, wwpn) || STRNEQ(expect_fabric_wwn, fabric_wwn) || STRNEQ(expect_max_vports, max_vports) || STRNEQ(expect_vports, vports)) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 /* Test virVHBAGetHostByWWN */ @@ -164,7 +161,6 @@ test4(const void *data G_GNUC_UNUSED) { const char *expect_hostname =3D "host5"; g_autofree char *hostname =3D NULL; - int ret =3D -1; =20 if (!(hostname =3D virVHBAGetHostByWWN(TEST_FC_HOST_PREFIX, "2001001b32a9da4e", @@ -172,11 +168,9 @@ test4(const void *data G_GNUC_UNUSED) return -1; =20 if (STRNEQ(hostname, expect_hostname)) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 /* Test virVHBAFindVportHost @@ -188,17 +182,14 @@ test5(const void *data G_GNUC_UNUSED) { const char *expect_hostname =3D "host5"; g_autofree char *hostname =3D NULL; - int ret =3D -1; =20 if (!(hostname =3D virVHBAFindVportHost(TEST_FC_HOST_PREFIX))) return -1; =20 if (STRNEQ(hostname, expect_hostname)) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 /* Test virVHBAGetConfig fabric name optional */ @@ -210,7 +201,6 @@ test6(const void *data G_GNUC_UNUSED) g_autofree char *wwnn =3D NULL; g_autofree char *wwpn =3D NULL; g_autofree char *fabric_wwn =3D NULL; - int ret =3D -1; =20 if (!(wwnn =3D virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM_= NO_FAB, "node_name"))) @@ -218,20 +208,18 @@ test6(const void *data G_GNUC_UNUSED) =20 if (!(wwpn =3D virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM_= NO_FAB, "port_name"))) - goto cleanup; + return -1; =20 if ((fabric_wwn =3D virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM_NO_FAB, "fabric_name"))) - goto cleanup; + return -1; =20 if (STRNEQ(expect_wwnn, wwnn) || STRNEQ(expect_wwpn, wwpn)) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 diff --git a/tests/lxcconf2xmltest.c b/tests/lxcconf2xmltest.c index be70671d68..09f6465567 100644 --- a/tests/lxcconf2xmltest.c +++ b/tests/lxcconf2xmltest.c @@ -25,33 +25,29 @@ testCompareXMLToConfigFiles(const char *xmlfile, const char *configfile, bool expectError) { - int ret =3D -1; g_autofree char *config =3D NULL; g_autofree char *actualxml =3D NULL; g_autoptr(virDomainDef) vmdef =3D NULL; =20 if (virTestLoadFile(configfile, &config) < 0) - goto fail; + return -1; =20 vmdef =3D lxcParseConfigString(config, driver->caps, driver->xmlopt); if ((vmdef && expectError) || (!vmdef && !expectError)) - goto fail; + return -1; =20 if (vmdef) { if (testSanitizeDef(vmdef) < 0) - goto fail; + return -1; =20 if (!(actualxml =3D virDomainDefFormat(vmdef, driver->xmlopt, 0))) - goto fail; + return -1; =20 if (virTestCompareToFile(actualxml, xmlfile) < 0) - goto fail; + return -1; } =20 - ret =3D 0; - - fail: - return ret; + return 0; } =20 struct testInfo { diff --git a/tests/metadatatest.c b/tests/metadatatest.c index 5112912161..b56428fde5 100644 --- a/tests/metadatatest.c +++ b/tests/metadatatest.c @@ -91,7 +91,6 @@ verifyMetadata(virDomainPtr dom, const char *expectAPI, const char *uri) { - bool ret =3D false; g_autofree char *metadataXML =3D NULL; g_autofree char *metadataAPI =3D NULL; =20 @@ -102,13 +101,13 @@ verifyMetadata(virDomainPtr dom, virReportError(VIR_ERR_INTERNAL_ERROR, "expected no metadata in API, but got:\n[%s]", metadataAPI); - goto cleanup; + return false; } } else { if (!(metadataAPI =3D virDomainGetMetadata(dom, VIR_DOMAIN_METADATA_ELEME= NT, uri, 0))) - goto cleanup; + return false; =20 metadataXMLConvertApostrophe(metadataAPI); =20 @@ -117,7 +116,7 @@ verifyMetadata(virDomainPtr dom, "XML metadata in API doesn't match expected met= adata: " "expected:\n[%s]\ngot:\n[%s]", expectAPI, metadataAPI); - goto cleanup; + return false; } =20 } @@ -127,11 +126,11 @@ verifyMetadata(virDomainPtr dom, virReportError(VIR_ERR_INTERNAL_ERROR, "expected no metadata in XML, but got:\n[%s]", metadataXML); - goto cleanup; + return false; } } else { if (!(metadataXML =3D getMetadataFromXML(dom))) - goto cleanup; + return false; =20 metadataXMLConvertApostrophe(metadataXML); =20 @@ -140,15 +139,11 @@ verifyMetadata(virDomainPtr dom, "XML in dump doesn't match expected metadata: " "expected:\n[%s]\ngot:\n[%s]", expectXML, metadataXML); - goto cleanup; + return false; } } =20 - ret =3D true; - - cleanup: - - return ret; + return true; } =20 =20 @@ -213,7 +208,6 @@ testTextMetadata(const void *data) { const struct metadataTest *test =3D data; g_autofree char *actual =3D NULL; - int ret =3D -1; =20 if (virDomainSetMetadata(test->dom, test->type, test->data, NULL, NULL= , 0) < 0) { if (test->fail) @@ -228,14 +222,10 @@ testTextMetadata(const void *data) "expected metadata doesn't match actual: " "expected:'%s'\ngot: '%s'", NULLSTR(test->data), NULLSTR(actual)); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - - return ret; + return 0; } =20 #define TEST_TEXT_METADATA(INDEX, TYPE, DATA, EXPECT, FAIL) \ diff --git a/tests/openvzutilstest.c b/tests/openvzutilstest.c index 3ebf38f104..7e6c0b60bb 100644 --- a/tests/openvzutilstest.c +++ b/tests/openvzutilstest.c @@ -36,7 +36,6 @@ static struct testConfigParam configParams[] =3D { static int testReadConfigParam(const void *data G_GNUC_UNUSED) { - int result =3D -1; size_t i; g_autofree char *conf =3D NULL; g_autofree char *value =3D NULL; @@ -46,7 +45,7 @@ testReadConfigParam(const void *data G_GNUC_UNUSED) for (i =3D 0; i < G_N_ELEMENTS(configParams); ++i) { if (openvzReadConfigParam(conf, configParams[i].param, &value) !=3D configParams[i].ret) { - goto cleanup; + return -1; } =20 if (configParams[i].ret !=3D 1) @@ -54,15 +53,11 @@ testReadConfigParam(const void *data G_GNUC_UNUSED) =20 if (STRNEQ(configParams[i].value, value)) { virTestDifference(stderr, configParams[i].value, value); - goto cleanup; + return -1; } } =20 - result =3D 0; - - cleanup: - - return result; + return 0; } =20 static int diff --git a/tests/scsihosttest.c b/tests/scsihosttest.c index aeb91da691..cb66a479e3 100644 --- a/tests/scsihosttest.c +++ b/tests/scsihosttest.c @@ -70,7 +70,6 @@ create_scsihost(const char *fakesysfsdir, const char *dev= icepath, g_autofree char *unique_id_path =3D NULL; g_autofree char *link_path =3D NULL; char *spot; - int ret =3D -1; VIR_AUTOCLOSE fd =3D -1; =20 unique_id_path =3D g_strdup_printf("%s/devices/pci0000:00/%s/unique_id= ", @@ -83,13 +82,13 @@ create_scsihost(const char *fakesysfsdir, const char *d= evicepath, */ if (!(spot =3D strstr(unique_id_path, "unique_id"))) { fprintf(stderr, "Did not find unique_id in path\n"); - goto cleanup; + return -1; } spot--; *spot =3D '\0'; if (g_mkdir_with_parents(unique_id_path, 0755) < 0) { fprintf(stderr, "Unable to make path to '%s'\n", unique_id_path); - goto cleanup; + return -1; } *spot =3D '/'; =20 @@ -98,45 +97,42 @@ create_scsihost(const char *fakesysfsdir, const char *d= evicepath, */ if (!(spot =3D strstr(link_path, hostname))) { fprintf(stderr, "Did not find hostname in path\n"); - goto cleanup; + return -1; } spot--; *spot =3D '\0'; if (g_mkdir_with_parents(link_path, 0755) < 0) { fprintf(stderr, "Unable to make path to '%s'\n", link_path); - goto cleanup; + return -1; } *spot =3D '/'; =20 if ((fd =3D open(unique_id_path, O_CREAT|O_WRONLY, 0444)) < 0) { fprintf(stderr, "Unable to create '%s'\n", unique_id_path); - goto cleanup; + return -1; } =20 if (safewrite(fd, unique_id, 1) !=3D 1) { fprintf(stderr, "Unable to write '%s'\n", unique_id); - goto cleanup; + return -1; } VIR_DEBUG("Created unique_id '%s'", unique_id_path); =20 /* The link is to the path not the file - so remove the file */ if (!(spot =3D strstr(unique_id_path, "unique_id"))) { fprintf(stderr, "Did not find unique_id in path\n"); - goto cleanup; + return -1; } spot--; *spot =3D '\0'; if (symlink(unique_id_path, link_path) < 0) { fprintf(stderr, "Unable to create symlink '%s' to '%s'\n", link_path, unique_id_path); - goto cleanup; + return -1; } VIR_DEBUG("Created symlink '%s'", link_path); =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabelt= est.c index 2e5941d7ef..87b2fc738a 100644 --- a/tests/securityselinuxlabeltest.c +++ b/tests/securityselinuxlabeltest.c @@ -99,7 +99,6 @@ testSELinuxLoadFileList(const char *testname, testSELinuxFile **files, size_t *nfiles) { - int ret =3D -1; g_autofree char *path =3D NULL; g_autoptr(FILE) fp =3D NULL; g_autofree char *line =3D NULL; @@ -111,7 +110,7 @@ testSELinuxLoadFileList(const char *testname, testname); =20 if (!(fp =3D fopen(path, "r"))) - goto cleanup; + return -1; =20 line =3D g_new0(char, 1024); =20 @@ -119,7 +118,7 @@ testSELinuxLoadFileList(const char *testname, char *file =3D NULL, *context =3D NULL, *tmp; if (!fgets(line, 1024, fp)) { if (!feof(fp)) - goto cleanup; + return -1; break; } =20 @@ -128,7 +127,7 @@ testSELinuxLoadFileList(const char *testname, virReportError(VIR_ERR_INTERNAL_ERROR, "unexpected format for line '%s'", line); - goto cleanup; + return -1; } *tmp =3D '\0'; tmp++; @@ -148,10 +147,7 @@ testSELinuxLoadFileList(const char *testname, (*files)[(*nfiles)-1].context =3D context; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 diff --git a/tests/vmwarevertest.c b/tests/vmwarevertest.c index 7cb358795f..cdbd58fb4f 100644 --- a/tests/vmwarevertest.c +++ b/tests/vmwarevertest.c @@ -37,7 +37,6 @@ static int testVerStrParse(const void *data) { const struct testInfo *info =3D data; - int ret =3D -1; g_autofree char *path =3D NULL; g_autofree char *databuf =3D NULL; unsigned long version; @@ -46,24 +45,21 @@ testVerStrParse(const void *data) path =3D g_strdup_printf("%s/vmwareverdata/%s.txt", abs_srcdir, info->= name); =20 if (virTestLoadFile(path, &databuf) < 0) - goto cleanup; + return -1; =20 if ((vmware_type =3D vmwareDriverTypeFromString(info->vmware_type)) < = 0) - goto cleanup; + return -1; =20 if (vmwareParseVersionStr(vmware_type, databuf, &version) < 0) - goto cleanup; + return -1; =20 if (version !=3D info->version) { fprintf(stderr, "%s: parsed versions do not match: got %lu, " "expected %lu\n", info->name, version, info->version); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int --=20 2.31.1