From nobody Mon Feb 9 04:30:40 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=1630788427; cv=none; d=zohomail.com; s=zohoarc; b=SXOfVDegleD7eeB3edS15REr8E2rgUn+ecy4qFqyCBRDAEzLsb3H0sMLaxau5zl8S+ltUA+jsawV/Wulw8ZstYq+zEJSH9nVehQHRw20B9uz6DJDqZ9M2s14B8nAYOe00l886HL5L7JrMBkKMDYCiOzXScbJ85CBJ8qsU5x6BFg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630788427; 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=IGUR0JRKcEvT/Zg2k5Q0To/B1fFWFe8oCfqQEBVgjUI=; b=IAt5PDsaz7HtEVN/ua0Je+J/76ayQGk/amQ+z9bVlmAoJo2gd4E46VewiuF4PQeVEX9cMytzV1UqPU60HNZSLMGDnEt9Bj1xMGFNjeuguyqnyZLqc6CZ0cMHtRZsCSNoA2ND3CyFq9IZc6fi8xljRyz/nnPhoexywZAplHV9anY= 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 1630788427271706.8788440618831; Sat, 4 Sep 2021 13:47:07 -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-457-oJzgQS6eNny4EHJGomZI1w-1; Sat, 04 Sep 2021 16:47:04 -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 347BF107ACCA; Sat, 4 Sep 2021 20:46:59 +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 1591E5FC23; Sat, 4 Sep 2021 20:46:59 +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 D9BCA44A62; Sat, 4 Sep 2021 20:46:58 +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 184KipOi008940 for ; Sat, 4 Sep 2021 16:44:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6B7E52619D; Sat, 4 Sep 2021 20:44:51 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id E80A51F4 for ; Sat, 4 Sep 2021 20:44:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630788426; 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=IGUR0JRKcEvT/Zg2k5Q0To/B1fFWFe8oCfqQEBVgjUI=; b=R2yS3LodWJEKu6R/i6UoHC3Afy8Zz3+02EKk6W4S4ypk2qtWPcNQPv4Ot6bdnFBaaSvpkd aa5qwf76iVqBkAtTREoHg8ANxOIzwOEIS3+r5LTWi1KBFqlxJbxY5Ob2IfkFMBmzflhdxf +qmpAT/oOkg2yBbHK7qJxpzcF+h+P9A= X-MC-Unique: oJzgQS6eNny4EHJGomZI1w-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 23/24] tests: vir: remove pointless labels Date: Sat, 4 Sep 2021 22:44:21 +0200 Message-Id: <5d757aeb1d679ae2164411d7d1b278a1c7094c45.1630788206.git.jtomko@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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1630788429142100001 Signed-off-by: J=C3=A1n Tomko --- tests/vircapstest.c | 14 +++------ tests/virconftest.c | 38 ++++++++++-------------- tests/vircryptotest.c | 23 +++++---------- tests/virfiletest.c | 49 ++++++++++++------------------- tests/virhostcputest.c | 12 +++----- tests/viriscsitest.c | 15 +++------- tests/virkmodtest.c | 30 ++++++------------- tests/virmacmaptest.c | 31 +++++++------------ tests/virnetworkportxml2xmltest.c | 15 ++++------ tests/virnumamock.c | 7 ++--- tests/virpcitest.c | 22 ++++++-------- tests/virresctrltest.c | 16 ++++------ tests/virscsitest.c | 15 +++------- tests/virstringtest.c | 32 +++++--------------- tests/virsystemdtest.c | 20 ++++--------- 15 files changed, 115 insertions(+), 224 deletions(-) diff --git a/tests/vircapstest.c b/tests/vircapstest.c index ebabbbb9a0..d1b5033844 100644 --- a/tests/vircapstest.c +++ b/tests/vircapstest.c @@ -153,10 +153,8 @@ test_virCapsDomainDataLookupQEMU(const void *data G_GN= UC_UNUSED) int ret =3D 0; g_autoptr(virCaps) caps =3D NULL; =20 - if (!(caps =3D testQemuCapsInit())) { - ret =3D -1; - goto out; - } + if (!(caps =3D testQemuCapsInit())) + return -1; =20 /* Checking each parameter individually */ CAPSCOMP(-1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_NONE, NULL, NULL, @@ -195,7 +193,6 @@ test_virCapsDomainDataLookupQEMU(const void *data G_GNU= C_UNUSED) "/usr/bin/qemu-system-aarch64", "pc"); CAPS_EXPECT_ERR(-1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_VMWARE, NULL, "pc"); =20 - out: return ret; } #endif /* WITH_QEMU */ @@ -207,10 +204,8 @@ test_virCapsDomainDataLookupLXC(const void *data G_GNU= C_UNUSED) int ret =3D 0; g_autoptr(virCaps) caps =3D NULL; =20 - if (!(caps =3D testLXCCapsInit())) { - ret =3D -1; - goto out; - } + if (!(caps =3D testLXCCapsInit())) + return -1; =20 CAPSCOMP(-1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_NONE, NULL, NULL, VIR_DOMAIN_OSTYPE_EXE, VIR_ARCH_X86_64, @@ -219,7 +214,6 @@ test_virCapsDomainDataLookupLXC(const void *data G_GNUC= _UNUSED) VIR_DOMAIN_OSTYPE_EXE, VIR_ARCH_X86_64, VIR_DOMAIN_VIRT_LXC, "/usr/libexec/libvirt_lxc", NULL); =20 - out: return ret; } #endif /* WITH_LXC */ diff --git a/tests/virconftest.c b/tests/virconftest.c index a7189579d3..5d1ad8a612 100644 --- a/tests/virconftest.c +++ b/tests/virconftest.c @@ -67,7 +67,6 @@ static int testConfMemoryNoNewline(const void *opaque G_G= NUC_UNUSED) "uint =3D 12345"; =20 g_autoptr(virConf) conf =3D virConfReadString(srcdata, 0); - int ret =3D -1; virConfValue *val; unsigned long long llvalue; g_autofree char *str =3D NULL; @@ -77,49 +76,47 @@ static int testConfMemoryNoNewline(const void *opaque G= _GNUC_UNUSED) return -1; =20 if (!(val =3D virConfGetValue(conf, "ullong"))) - goto cleanup; + return -1; =20 if (val->type !=3D VIR_CONF_STRING) - goto cleanup; + return -1; =20 if (virStrToLong_ull(val->str, NULL, 10, &llvalue) < 0) - goto cleanup; + return -1; =20 if (llvalue !=3D 123456789) { fprintf(stderr, "Expected '123' got '%llu'\n", llvalue); - goto cleanup; + return -1; } =20 if (virConfGetValueType(conf, "string") !=3D VIR_CONF_STRING) { fprintf(stderr, "expected a string for 'string'\n"); - goto cleanup; + return -1; } =20 if (virConfGetValueString(conf, "string", &str) < 0) - goto cleanup; + return -1; =20 if (STRNEQ_NULLABLE(str, "foo")) { fprintf(stderr, "Expected 'foo' got '%s'\n", str); - goto cleanup; + return -1; } =20 if (virConfGetValueType(conf, "uint") !=3D VIR_CONF_ULLONG) { fprintf(stderr, "expected an unsigned long for 'uint'\n"); - goto cleanup; + return -1; } =20 if (virConfGetValueInt(conf, "uint", &uintvalue) < 0) - goto cleanup; + return -1; =20 if (uintvalue !=3D 12345) { fprintf(stderr, "Expected 12345 got %ud\n", uintvalue); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -338,7 +335,6 @@ static int testConfParseString(const void *opaque G_GNU= C_UNUSED) "int =3D 6963472309248\n" \ "string =3D \"foo\"\n"; =20 - int ret =3D -1; g_autoptr(virConf) conf =3D virConfReadString(srcdata, 0); g_autofree char *str =3D NULL; =20 @@ -348,25 +344,23 @@ static int testConfParseString(const void *opaque G_G= NUC_UNUSED) if (virConfGetValueType(conf, "string") !=3D VIR_CONF_STRING) { fprintf(stderr, "expected a string for 'string'\n"); - goto cleanup; + return -1; } =20 if (virConfGetValueString(conf, "string", &str) < 0) - goto cleanup; + return -1; =20 if (STRNEQ_NULLABLE(str, "foo")) { fprintf(stderr, "Expected 'foo' got '%s'\n", str); - goto cleanup; + return -1; } =20 if (virConfGetValueString(conf, "int", &str) !=3D -1) { fprintf(stderr, "Expected error for 'int'\n"); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 diff --git a/tests/vircryptotest.c b/tests/vircryptotest.c index 2d503a439e..98af476156 100644 --- a/tests/vircryptotest.c +++ b/tests/vircryptotest.c @@ -38,22 +38,19 @@ testCryptoHash(const void *opaque) { const struct testCryptoHashData *data =3D opaque; g_autofree char *actual =3D NULL; - int ret =3D -1; =20 if (virCryptoHashString(data->hash, data->input, &actual) < 0) { fprintf(stderr, "Failed to generate crypto hash\n"); - goto cleanup; + return -1; } =20 if (STRNEQ_NULLABLE(data->output, actual)) { fprintf(stderr, "Expected hash '%s' but got '%s'\n", data->output, NULLSTR(actual)); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -75,7 +72,6 @@ testCryptoEncrypt(const void *opaque) size_t ivlen =3D 16; g_autofree uint8_t *ciphertext =3D NULL; size_t ciphertextlen =3D 0; - int ret =3D -1; =20 if (!virCryptoHaveCipher(data->algorithm)) { fprintf(stderr, "cipher algorithm=3D%d unavailable\n", data->algor= ithm); @@ -88,29 +84,26 @@ testCryptoEncrypt(const void *opaque) if (virRandomBytes(enckey, enckeylen) < 0 || virRandomBytes(iv, ivlen) < 0) { fprintf(stderr, "Failed to generate random bytes\n"); - goto cleanup; + return -1; } =20 if (virCryptoEncryptData(data->algorithm, enckey, enckeylen, iv, ivlen, data->input, data->inputlen, &ciphertext, &ciphertextlen) < 0) - goto cleanup; + return -1; =20 if (data->ciphertextlen !=3D ciphertextlen) { fprintf(stderr, "Expected ciphertextlen(%zu) doesn't match (%zu)\n= ", data->ciphertextlen, ciphertextlen); - goto cleanup; + return -1; } =20 if (memcmp(data->ciphertext, ciphertext, ciphertextlen)) { fprintf(stderr, "Expected ciphertext doesn't match\n"); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - - return ret; + return 0; } =20 =20 diff --git a/tests/virfiletest.c b/tests/virfiletest.c index a6e722b4d2..4b69ea1b69 100644 --- a/tests/virfiletest.c +++ b/tests/virfiletest.c @@ -103,7 +103,6 @@ static int testFileSanitizePath(const void *opaque) { const struct testFileSanitizePathData *data =3D opaque; - int ret =3D -1; g_autofree char *actual =3D NULL; =20 if (!(actual =3D virFileSanitizePath(data->path))) @@ -111,13 +110,10 @@ testFileSanitizePath(const void *opaque) =20 if (STRNEQ(actual, data->expect)) { fprintf(stderr, "\nexpect: '%s'\nactual: '%s'\n", data->expect, ac= tual); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -195,41 +191,38 @@ holesSupported(void) off_t offsets[] =3D {EXTENT, EXTENT, EXTENT, -1}; off_t tmp; VIR_AUTOCLOSE fd =3D -1; - bool ret =3D false; =20 if ((fd =3D makeSparseFile(offsets, true)) < 0) - goto cleanup; + return false; =20 /* The way this works is: there are 4K of data followed by 4K hole fol= lowed * by 4K hole again. Check if the filesystem we are running the test s= uite * on supports holes. */ if ((tmp =3D lseek(fd, 0, SEEK_DATA)) =3D=3D (off_t) -1) - goto cleanup; + return false; =20 if (tmp !=3D 0) - goto cleanup; + return false; =20 if ((tmp =3D lseek(fd, tmp, SEEK_HOLE)) =3D=3D (off_t) -1) - goto cleanup; + return false; =20 if (tmp !=3D EXTENT * 1024) - goto cleanup; + return false; =20 if ((tmp =3D lseek(fd, tmp, SEEK_DATA)) =3D=3D (off_t) -1) - goto cleanup; + return false; =20 if (tmp !=3D 2 * EXTENT * 1024) - goto cleanup; + return false; =20 if ((tmp =3D lseek(fd, tmp, SEEK_HOLE)) =3D=3D (off_t) -1) - goto cleanup; + return false; =20 if (tmp !=3D 3 * EXTENT * 1024) - goto cleanup; + return false; =20 - ret =3D true; - cleanup: - return ret; + return true; } =20 #else /* !WITH_DECL_SEEK_HOLE || !defined(__linux__)*/ @@ -261,11 +254,10 @@ testFileInData(const void *opaque) { const struct testFileInData *data =3D opaque; VIR_AUTOCLOSE fd =3D -1; - int ret =3D -1; size_t i; =20 if ((fd =3D makeSparseFile(data->offsets, data->startData)) < 0) - goto cleanup; + return -1; =20 for (i =3D 0; data->offsets[i] !=3D (off_t) -1; i++) { bool shouldInData =3D data->startData; @@ -277,32 +269,29 @@ testFileInData(const void *opaque) shouldInData =3D !shouldInData; =20 if (virFileInData(fd, &realInData, &realLen) < 0) - goto cleanup; + return -1; =20 if (realInData !=3D shouldInData) { fprintf(stderr, "Unexpected data/hole. Expected %s got %s\n", shouldInData ? "data" : "hole", realInData ? "data" : "hole"); - goto cleanup; + return -1; } =20 shouldLen =3D data->offsets[i] * 1024; if (realLen !=3D shouldLen) { fprintf(stderr, "Unexpected section length. Expected %lld got = %lld\n", shouldLen, realLen); - goto cleanup; + return -1; } =20 if (lseek(fd, shouldLen, SEEK_CUR) < 0) { fprintf(stderr, "Unable to seek\n"); - goto cleanup; + return -1; } } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -319,9 +308,9 @@ testFileIsSharedFSType(const void *opaque G_GNUC_UNUSED) return EXIT_AM_SKIP; #else const struct testFileIsSharedFSType *data =3D opaque; + int ret =3D -1; g_autofree char *mtabFile =3D NULL; bool actual; - int ret =3D -1; =20 mtabFile =3D g_strdup_printf(abs_srcdir "/virfiledata/%s", data->mtabF= ile); =20 diff --git a/tests/virhostcputest.c b/tests/virhostcputest.c index c80cd1581c..746e65727f 100644 --- a/tests/virhostcputest.c +++ b/tests/virhostcputest.c @@ -30,7 +30,6 @@ linuxTestCompareFiles(const char *cpuinfofile, virArch arch, const char *outputfile) { - int ret =3D -1; g_autofree char *actualData =3D NULL; virNodeInfo nodeinfo; g_autoptr(FILE) cpuinfo =3D NULL; @@ -39,7 +38,7 @@ linuxTestCompareFiles(const char *cpuinfofile, if (!cpuinfo) { fprintf(stderr, "unable to open: %s : %s\n", cpuinfofile, g_strerror(errno)); - goto fail; + return -1; } =20 memset(&nodeinfo, 0, sizeof(nodeinfo)); @@ -51,7 +50,7 @@ linuxTestCompareFiles(const char *cpuinfofile, if (virGetLastErrorCode()) VIR_TEST_DEBUG("\n%s", virGetLastErrorMessage()); } - goto fail; + return -1; } =20 actualData =3D g_strdup_printf("CPUs: %u/%u, MHz: %u, Nodes: %u, Socke= ts: %u, " @@ -61,12 +60,9 @@ linuxTestCompareFiles(const char *cpuinfofile, nodeinfo.cores, nodeinfo.threads); =20 if (virTestCompareToFile(actualData, outputfile) < 0) - goto fail; + return -1; =20 - ret =3D 0; - - fail: - return ret; + return 0; } =20 =20 diff --git a/tests/viriscsitest.c b/tests/viriscsitest.c index 7ea761fda6..f2539e47b0 100644 --- a/tests/viriscsitest.c +++ b/tests/viriscsitest.c @@ -211,7 +211,6 @@ testISCSIGetSession(const void *data) const struct testSessionInfo *info =3D data; struct testIscsiadmCbData cbData =3D { 0 }; g_autofree char *actual_session =3D NULL; - int ret =3D -1; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 cbData.output_version =3D info->output_version; @@ -225,13 +224,10 @@ testISCSIGetSession(const void *data) "Expected session: '%s' got: '%s'", NULLSTR(info->expected_session), NULLSTR(actual_session)); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 struct testScanTargetsInfo { @@ -295,17 +291,14 @@ testISCSIConnectionLogin(const void *data) { const struct testConnectionInfoLogin *info =3D data; struct testIscsiadmCbData cbData =3D { 0 }; - int ret =3D -1; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 virCommandSetDryRun(dryRunToken, NULL, false, false, testIscsiadmCb, &= cbData); =20 if (virISCSIConnectionLogin(info->portal, info->initiatoriqn, info->ta= rget) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 diff --git a/tests/virkmodtest.c b/tests/virkmodtest.c index 2f07757c88..d2df3bdb04 100644 --- a/tests/virkmodtest.c +++ b/tests/virkmodtest.c @@ -34,30 +34,25 @@ static int checkOutput(virBuffer *buf, const char *exp_cmd) { - int ret =3D -1; g_autofree char *actual_cmd =3D NULL; =20 if (!(actual_cmd =3D virBufferContentAndReset(buf))) { fprintf(stderr, "cannot compare buffer to exp: %s", exp_cmd); - goto cleanup; + return -1; } =20 if (STRNEQ(exp_cmd, actual_cmd)) { virTestDifference(stderr, exp_cmd, actual_cmd); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 static int testKModLoad(const void *args G_GNUC_UNUSED) { - int ret =3D -1; g_autofree char *errbuf =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); @@ -67,23 +62,19 @@ testKModLoad(const void *args G_GNUC_UNUSED) errbuf =3D virKModLoad(MODNAME); if (errbuf) { fprintf(stderr, "Failed to load, error: %s\n", errbuf); - goto cleanup; + return -1; } =20 if (checkOutput(&buf, MODPROBE " -b " MODNAME "\n") < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 static int testKModUnload(const void *args G_GNUC_UNUSED) { - int ret =3D -1; g_autofree char *errbuf =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); @@ -93,16 +84,13 @@ testKModUnload(const void *args G_GNUC_UNUSED) errbuf =3D virKModUnload(MODNAME); if (errbuf) { fprintf(stderr, "Failed to unload, error: %s\n", errbuf); - goto cleanup; + return -1; } =20 if (checkOutput(&buf, RMMOD " " MODNAME "\n") < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 diff --git a/tests/virmacmaptest.c b/tests/virmacmaptest.c index 01a3588ed9..9a28c1bed0 100644 --- a/tests/virmacmaptest.c +++ b/tests/virmacmaptest.c @@ -40,12 +40,11 @@ testMACLookup(const void *opaque) GSList *next; size_t i, j; g_autofree char *file =3D NULL; - int ret =3D -1; =20 file =3D g_strdup_printf("%s/virmacmaptestdata/%s.json", abs_srcdir, d= ata->file); =20 if (!(mgr =3D virMacMapNew(file))) - goto cleanup; + return -1; =20 macs =3D virMacMapLookup(mgr, data->domain); =20 @@ -59,7 +58,7 @@ testMACLookup(const void *opaque) fprintf(stderr, "Unexpected %s in the returned list of MACs\n", (const char *) next->data); - goto cleanup; + return -1; } } =20 @@ -72,13 +71,11 @@ testMACLookup(const void *opaque) if (!next) { fprintf(stderr, "Expected %s in the returned list of MACs\n", data->ma= cs[i]); - goto cleanup; + return -1; } } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -90,18 +87,17 @@ testMACRemove(const void *opaque) GSList *macs; size_t i; g_autofree char *file =3D NULL; - int ret =3D -1; =20 file =3D g_strdup_printf("%s/virmacmaptestdata/%s.json", abs_srcdir, d= ata->file); =20 if (!(mgr =3D virMacMapNew(file))) - goto cleanup; + return -1; =20 for (i =3D 0; data->macs && data->macs[i]; i++) { if (virMacMapRemove(mgr, data->domain, data->macs[i]) < 0) { fprintf(stderr, "Error when removing %s from the list of MACs\n", data= ->macs[i]); - goto cleanup; + return -1; } } =20 @@ -109,12 +105,10 @@ testMACRemove(const void *opaque) fprintf(stderr, "Not removed all MACs for domain %s: %s\n", data->domain, (const char *) macs->data); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -124,19 +118,16 @@ testMACFlush(const void *opaque) const struct testData *data =3D opaque; g_autofree char *file =3D NULL; g_autofree char *str =3D NULL; - int ret =3D -1; =20 file =3D g_strdup_printf("%s/virmacmaptestdata/%s.json", abs_srcdir, d= ata->file); =20 if (virMacMapDumpStr(data->mgr, &str) < 0) - goto cleanup; + return -1; =20 if (virTestCompareToFile(str, file) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 diff --git a/tests/virnetworkportxml2xmltest.c b/tests/virnetworkportxml2xm= ltest.c index 8d29db724f..093d855633 100644 --- a/tests/virnetworkportxml2xmltest.c +++ b/tests/virnetworkportxml2xmltest.c @@ -37,21 +37,18 @@ static int testCompareXMLToXMLFiles(const char *expected) { g_autofree char *actual =3D NULL; - int ret =3D -1; g_autoptr(virNetworkPortDef) dev =3D NULL; =20 if (!(dev =3D virNetworkPortDefParseFile(expected))) - goto cleanup; + return -1; =20 if (!(actual =3D virNetworkPortDefFormat(dev))) - goto cleanup; + return -1; =20 if (virTestCompareToFile(actual, expected) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 struct testInfo { @@ -62,14 +59,12 @@ static int testCompareXMLToXMLHelper(const void *data) { const struct testInfo *info =3D data; - int ret =3D -1; g_autofree char *xml =3D NULL; =20 xml =3D g_strdup_printf("%s/virnetworkportxml2xmldata/%s.xml", abs_src= dir, info->name); =20 - ret =3D testCompareXMLToXMLFiles(xml); - return ret; + return testCompareXMLToXMLFiles(xml); } =20 static int diff --git a/tests/virnumamock.c b/tests/virnumamock.c index 6e0293a49e..19c26d1e37 100644 --- a/tests/virnumamock.c +++ b/tests/virnumamock.c @@ -162,7 +162,6 @@ virNumaGetPages(int node, int virNumaGetNodeCPUs(int node, virBitmap **cpus) { - int ret =3D -1; g_autofree char *cpulist =3D NULL; =20 if (virFileReadValueString(&cpulist, @@ -177,9 +176,7 @@ virNumaGetNodeCPUs(int node, virBitmap **cpus) *cpus =3D virBitmapParseUnlimited(cpulist); } if (!*cpus) - goto cleanup; + return -1; =20 - ret =3D virBitmapCountBits(*cpus); - cleanup: - return ret; + return virBitmapCountBits(*cpus); } diff --git a/tests/virpcitest.c b/tests/virpcitest.c index 1ff0330b22..08e137756f 100644 --- a/tests/virpcitest.c +++ b/tests/virpcitest.c @@ -34,22 +34,19 @@ testVirPCIDeviceCheckDriver(virPCIDevice *dev, const ch= ar *expected) { g_autofree char *path =3D NULL; g_autofree char *driver =3D NULL; - int ret =3D -1; =20 if (virPCIDeviceGetDriverPathAndName(dev, &path, &driver) < 0) - goto cleanup; + return -1; =20 if (STRNEQ_NULLABLE(driver, expected)) { virReportError(VIR_ERR_INTERNAL_ERROR, "PCI device %s driver mismatch: %s, expecting %s", virPCIDeviceGetName(dev), NULLSTR(driver), NULLSTR(expected)); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 static int @@ -166,7 +163,6 @@ testVirPCIDeviceReset(const void *opaque G_GNUC_UNUSED) static int testVirPCIDeviceReattach(const void *opaque G_GNUC_UNUSED) { - int ret =3D -1; virPCIDevice *dev[] =3D {NULL, NULL, NULL}; size_t i, nDev =3D G_N_ELEMENTS(dev); g_autoptr(virPCIDeviceList) activeDevs =3D NULL; @@ -175,17 +171,17 @@ testVirPCIDeviceReattach(const void *opaque G_GNUC_UN= USED) =20 if (!(activeDevs =3D virPCIDeviceListNew()) || !(inactiveDevs =3D virPCIDeviceListNew())) - goto cleanup; + return -1; =20 for (i =3D 0; i < nDev; i++) { virPCIDeviceAddress devAddr =3D {.domain =3D 0, .bus =3D 0, .slot =3D i + 1, .function =3D 0}; if (!(dev[i] =3D virPCIDeviceNew(&devAddr))) - goto cleanup; + return -1; =20 if (virPCIDeviceListAdd(inactiveDevs, dev[i]) < 0) { virPCIDeviceFree(dev[i]); - goto cleanup; + return -1; } =20 CHECK_LIST_COUNT(activeDevs, 0); @@ -199,15 +195,15 @@ testVirPCIDeviceReattach(const void *opaque G_GNUC_UN= USED) =20 for (i =3D 0; i < nDev; i++) { if (virPCIDeviceReattach(dev[i], activeDevs, inactiveDevs) < 0) - goto cleanup; + return -1; =20 CHECK_LIST_COUNT(activeDevs, 0); CHECK_LIST_COUNT(inactiveDevs, nDev - i - 1); } =20 - ret =3D 0; + return 0; cleanup: - return ret; + return -1; } =20 struct testPCIDevData { diff --git a/tests/virresctrltest.c b/tests/virresctrltest.c index 0beb9a4df4..c5733a7972 100644 --- a/tests/virresctrltest.c +++ b/tests/virresctrltest.c @@ -20,7 +20,6 @@ test_virResctrlGetUnused(const void *opaque) struct virResctrlData *data =3D (struct virResctrlData *) opaque; g_autofree char *system_dir =3D NULL; g_autofree char *resctrl_dir =3D NULL; - int ret =3D -1; g_autoptr(virResctrlAlloc) alloc =3D NULL; g_autofree char *schemata_str =3D NULL; g_autofree char *schemata_file =3D NULL; @@ -41,7 +40,7 @@ test_virResctrlGetUnused(const void *opaque) caps =3D virCapabilitiesNew(VIR_ARCH_X86_64, false, false); if (!caps || virCapabilitiesInitCaches(caps) < 0) { fprintf(stderr, "Could not initialize capabilities"); - goto cleanup; + return -1; } =20 alloc =3D virResctrlAllocGetUnused(caps->host.resctrl); @@ -50,22 +49,19 @@ test_virResctrlGetUnused(const void *opaque) =20 if (!alloc) { if (data->fail) - ret =3D 0; - goto cleanup; + return 0; + return -1; } else if (data->fail) { VIR_TEST_DEBUG("Error expected but there wasn't any."); - ret =3D -1; - goto cleanup; + return -1; } =20 schemata_str =3D virResctrlAllocFormat(alloc); =20 if (virTestCompareToFile(schemata_str, schemata_file) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 diff --git a/tests/virscsitest.c b/tests/virscsitest.c index d67cd23896..c96699e157 100644 --- a/tests/virscsitest.c +++ b/tests/virscsitest.c @@ -37,18 +37,15 @@ static int test1(const void *data G_GNUC_UNUSED) { g_autofree char *name =3D NULL; - int ret =3D -1; =20 if (!(name =3D virSCSIDeviceGetDevName(virscsi_prefix, "scsi_host1", 0, 0, 0))) return -1; =20 if (STRNEQ(name, "sdh")) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 /* @@ -161,7 +158,6 @@ test2(const void *data G_GNUC_UNUSED) static int create_symlink(const char *tmpdir, const char *src_name, const char *dst_n= ame) { - int ret =3D -1; g_autofree char *src_path =3D NULL; g_autofree char *dst_path =3D NULL; =20 @@ -171,13 +167,10 @@ create_symlink(const char *tmpdir, const char *src_na= me, const char *dst_name) =20 if (symlink(src_path, dst_path) < 0) { VIR_WARN("Failed to create symlink '%s' to '%s'", src_path, dst_pa= th); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int diff --git a/tests/virstringtest.c b/tests/virstringtest.c index bbdd17da84..277deca934 100644 --- a/tests/virstringtest.c +++ b/tests/virstringtest.c @@ -223,7 +223,6 @@ testStringReplace(const void *opaque G_GNUC_UNUSED) { const struct stringReplaceData *data =3D opaque; g_autofree char *result =3D NULL; - int ret =3D -1; =20 result =3D virStringReplace(data->haystack, data->oldneedle, @@ -232,13 +231,10 @@ testStringReplace(const void *opaque G_GNUC_UNUSED) if (STRNEQ_NULLABLE(data->result, result)) { fprintf(stderr, "Expected '%s' but got '%s'\n", data->result, NULLSTR(result)); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -400,7 +396,6 @@ struct testStripData { static int testStripIPv6Brackets(const void *args) { const struct testStripData *data =3D args; - int ret =3D -1; g_autofree char *res =3D NULL; =20 res =3D g_strdup(data->string); @@ -410,19 +405,15 @@ static int testStripIPv6Brackets(const void *args) if (STRNEQ_NULLABLE(res, data->result)) { fprintf(stderr, "Returned '%s', expected '%s'\n", NULLSTR(res), NULLSTR(data->result)); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int testStripControlChars(const void *args) { const struct testStripData *data =3D args; - int ret =3D -1; g_autofree char *res =3D NULL; =20 res =3D g_strdup(data->string); @@ -432,13 +423,10 @@ static int testStripControlChars(const void *args) if (STRNEQ_NULLABLE(res, data->result)) { fprintf(stderr, "Returned '%s', expected '%s'\n", NULLSTR(res), NULLSTR(data->result)); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 struct testFilterData { @@ -450,7 +438,6 @@ struct testFilterData { static int testFilterChars(const void *args) { const struct testFilterData *data =3D args; - int ret =3D -1; g_autofree char *res =3D NULL; =20 res =3D g_strdup(data->string); @@ -460,13 +447,10 @@ static int testFilterChars(const void *args) if (STRNEQ_NULLABLE(res, data->result)) { fprintf(stderr, "Returned '%s', expected '%s'\n", NULLSTR(res), NULLSTR(data->result)); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int diff --git a/tests/virsystemdtest.c b/tests/virsystemdtest.c index 9cf6bfec43..9a063dd1fc 100644 --- a/tests/virsystemdtest.c +++ b/tests/virsystemdtest.c @@ -369,45 +369,37 @@ static int testScopeName(const void *opaque) { const struct testNameData *data =3D opaque; - int ret =3D -1; g_autofree char *actual =3D NULL; =20 if (!(actual =3D virSystemdMakeScopeName(data->name, "lxc", data->lega= cy))) - goto cleanup; + return -1; =20 if (STRNEQ(actual, data->expected)) { fprintf(stderr, "Expected '%s' but got '%s'\n", data->expected, actual); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int testMachineName(const void *opaque) { const struct testNameData *data =3D opaque; - int ret =3D -1; g_autofree char *actual =3D NULL; =20 if (!(actual =3D virDomainDriverGenerateMachineName("qemu", data->root, data->id, data->name= , true))) - goto cleanup; + return -1; =20 if (STRNEQ(actual, data->expected)) { fprintf(stderr, "Expected '%s' but got '%s'\n", data->expected, actual); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 typedef int (*virSystemdCanHelper)(bool * result); --=20 2.31.1