From nobody Sun Feb 8 16:30:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1571737233; cv=none; d=zoho.com; s=zohoarc; b=n4ZpMxcXNwez1XNjZwwQfl9Aln9mRxieJAIC6OcBMoiIRKlG6yTJ5YY76oXdxaJJIFioy2G7P4qz3yKx+ggY9xbgWRREnUsFwIKrOIYW+E6w3GTIN/t97aK4/DU52tPRnqkkB55Sy273zkuw6QNt/wHTiFDcDzkJyi9koAGF0zg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571737233; h=Content-Type:Content-Transfer-Encoding:Cc: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=R+AjSssBf5NIQwpA3b3bFs57CAitvUDNJKq6Vmx8x9Y=; b=eIDg2/Bz+GOWjw7eP9gnkS3BtpsO7pTEH6/7CgOf3CiC7mQesxQ38i7Ljd/rN+d/G4FU6hxAIUqgjP6VQ/VEomGF8Da/A06oH7VBSw3jzW+1cdOXbDnY4ccKEOfuh78k4CGEJiCgcOgFM4yzzR5MmVQ392xZOwztydtbuVvqYeg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1571737233246427.11728462553026; Tue, 22 Oct 2019 02:40:33 -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-180-lbWRvTXCOYWB-mI_FMbHpQ-1; Tue, 22 Oct 2019 05:40:30 -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 A87C91800D79; Tue, 22 Oct 2019 09:40:25 +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 818E36C060; Tue, 22 Oct 2019 09:40:25 +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 327CD181A82C; Tue, 22 Oct 2019 09:40:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9LIJv4j000739 for ; Mon, 21 Oct 2019 14:19:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4479B5C219; Mon, 21 Oct 2019 18:19:57 +0000 (UTC) Received: from mx1.redhat.com (ext-mx23.extmail.prod.ext.phx2.redhat.com [10.5.110.64]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 38D8D5C207 for ; Mon, 21 Oct 2019 18:19:57 +0000 (UTC) Received: from mail-qt1-f194.google.com (mail-qt1-f194.google.com [209.85.160.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 695C010A8128 for ; Mon, 21 Oct 2019 18:19:55 +0000 (UTC) Received: by mail-qt1-f194.google.com with SMTP id g50so8316136qtb.4 for ; Mon, 21 Oct 2019 11:19:55 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c6:7979:d16f:4e5e:8e8d:1141]) by smtp.gmail.com with ESMTPSA id d205sm9248741qke.96.2019.10.21.11.19.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 11:19:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571737232; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=R+AjSssBf5NIQwpA3b3bFs57CAitvUDNJKq6Vmx8x9Y=; b=cUWSxVsDc/1AYGE6pDzMr259IpGP/2K85UQWrLPDMYfTfaze/kzd4SHVHA0srCW8Fwykk9 KqXArsdbYBgGGnhdTClr5MR6E6eEBknpRoUny5dwufwmgk9RMMwBJi9s/CFVUYzPJ9GF8t 22f7xOqwnrwcg5o/b2KpQUGFvneS5qk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nr9HWc7ti5gsbgqUQbtkGXQ4BNKoGpqX7a8FHzIuf48=; b=NSjwZCrjP4CpJXC8tgWTCxUvM7hi9JFSBCtk46E+cm4anxObrRA1INSFSauCXUscMD 4tDr5eZzBdb65HtVrmMjMkFBfEhSJykK6diazDjoVdm0nLmhBYcK7O0Tri+QXxoKB8p3 SGv3irK1AXTwJDlPeD5Y/8d1NGa7IhKDFhqunKoBmRRzoqjqj+1yv7XcRcY0SaguEP2O wCYpwzL6k9NIwTrB4X8dn1CURMDi5eEvTr/AP1huhn0iCt5hllxtGfw3WlSdiqNQ4QLT OevoV2tx5oqv0V2kURUs4NbRfHylEGy8KYuEZBQGWs2zwmynWgS4Q4VYWO2y8rbsLixx YRBQ== X-Gm-Message-State: APjAAAXVQCR3aWIpvGuuYL/Zkv4rJ1ADS1uxqVxzlA9pbHge9uSwrV17 8oe2vOLxH5flY4AbNhdw87eWmApNynk= X-Google-Smtp-Source: APXvYqwM6xeb8MglWbi558G4C5ftC0ljTqAmcPisK76dnc0SQGg9a5SOVwiwZusyRb1zC7+IKdJ9lw== X-Received: by 2002:ac8:29c8:: with SMTP id 8mr24933251qtt.32.1571681993606; Mon, 21 Oct 2019 11:19:53 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Mon, 21 Oct 2019 15:19:10 -0300 Message-Id: <20191021181911.14986-21-danielhb413@gmail.com> In-Reply-To: <20191021181911.14986-1-danielhb413@gmail.com> References: <20191021181911.14986-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.64]); Mon, 21 Oct 2019 18:19:55 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.64]); Mon, 21 Oct 2019 18:19:55 +0000 (UTC) for IP:'209.85.160.194' DOMAIN:'mail-qt1-f194.google.com' HELO:'mail-qt1-f194.google.com' FROM:'danielhb413@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.131 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS) 209.85.160.194 mail-qt1-f194.google.com 209.85.160.194 mail-qt1-f194.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.64 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza Subject: [libvirt] [PATCH v1 20/21] tests: remove unneeded cleanup labels 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 X-MC-Unique: lbWRvTXCOYWB-mI_FMbHpQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Daniel Henrique Barboza --- tests/commandtest.c | 17 ++++---- tests/domainconftest.c | 5 +-- tests/networkxml2firewalltest.c | 13 ++---- tests/nsstest.c | 27 ++++++------- tests/nwfilterebiptablestest.c | 4 +- tests/nwfilterxml2firewalltest.c | 16 +++----- tests/qemuhotplugtest.c | 19 ++++----- tests/qemuxml2argvtest.c | 11 ++--- tests/storagebackendsheepdogtest.c | 5 +-- tests/virauthconfigtest.c | 11 ++--- tests/vircgroupmock.c | 11 ++--- tests/virendiantest.c | 58 ++++++++++++-------------- tests/virkeycodetest.c | 14 ++----- tests/virmacmaptest.c | 5 +-- tests/virnetdevtest.c | 11 ++--- tests/virpcimock.c | 31 +++++--------- tests/virpcitest.c | 3 +- tests/virpolkittest.c | 65 +++++++++--------------------- tests/virstringtest.c | 18 +++------ 19 files changed, 126 insertions(+), 218 deletions(-) diff --git a/tests/commandtest.c b/tests/commandtest.c index 6ff2039ab1..4fbbde9559 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -949,12 +949,11 @@ test23(const void *unused G_GNUC_UNUSED) /* Not strictly a virCommand test, but this is the easiest place * to test this lower-level interface. It takes a double fork to * test virProcessExitWithStatus. */ - int ret =3D -1; int status =3D -1; pid_t pid; =20 if ((pid =3D virFork()) < 0) - goto cleanup; + return -1; if (pid =3D=3D 0) { if ((pid =3D virFork()) < 0) _exit(EXIT_FAILURE); @@ -967,14 +966,14 @@ test23(const void *unused G_GNUC_UNUSED) } =20 if (virProcessWait(pid, &status, true) < 0) - goto cleanup; + return -1; if (!WIFEXITED(status) || WEXITSTATUS(status) !=3D 42) { printf("Unexpected status %d\n", status); - goto cleanup; + return -1; } =20 if ((pid =3D virFork()) < 0) - goto cleanup; + return -1; if (pid =3D=3D 0) { if ((pid =3D virFork()) < 0) _exit(EXIT_FAILURE); @@ -989,15 +988,13 @@ test23(const void *unused G_GNUC_UNUSED) } =20 if (virProcessWait(pid, &status, true) < 0) - goto cleanup; + return -1; if (!WIFSIGNALED(status) || WTERMSIG(status) !=3D SIGKILL) { printf("Unexpected status %d\n", status); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 static int test25(const void *unused G_GNUC_UNUSED) diff --git a/tests/domainconftest.c b/tests/domainconftest.c index e7bdc99438..5b7bf4bbec 100644 --- a/tests/domainconftest.c +++ b/tests/domainconftest.c @@ -83,10 +83,10 @@ mymain(void) int ret =3D 0; =20 if ((caps =3D virTestGenericCapsInit()) =3D=3D NULL) - goto cleanup; + return EXIT_SUCCESS; =20 if (!(xmlopt =3D virTestGenericDomainXMLConfInit())) - goto cleanup; + return EXIT_SUCCESS; =20 #define DO_TEST_GET_FS(fspath, expect) \ do { \ @@ -107,7 +107,6 @@ mymain(void) virObjectUnref(caps); virObjectUnref(xmlopt); =20 - cleanup: return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 diff --git a/tests/networkxml2firewalltest.c b/tests/networkxml2firewalltes= t.c index b8e974971a..6ee311f384 100644 --- a/tests/networkxml2firewalltest.c +++ b/tests/networkxml2firewalltest.c @@ -165,20 +165,16 @@ mymain(void) return EXIT_AM_SKIP; } =20 - ret =3D -1; - goto cleanup; + return EXIT_FAILURE; } =20 if (virAsprintf(&basefile, "%s/networkxml2firewalldata/base.args", abs_srcdir) < 0) { - ret =3D -1; - goto cleanup; + return EXIT_FAILURE; } =20 - if (virTestLoadFile(basefile, &baseargs) < 0) { - ret =3D -1; - goto cleanup; - } + if (virTestLoadFile(basefile, &baseargs) < 0) + return EXIT_FAILURE; =20 DO_TEST("nat-default"); DO_TEST("nat-tftp"); @@ -187,7 +183,6 @@ mymain(void) DO_TEST("nat-ipv6"); DO_TEST("route-default"); =20 - cleanup: return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 diff --git a/tests/nsstest.c b/tests/nsstest.c index 734e4cbc07..d146100747 100644 --- a/tests/nsstest.c +++ b/tests/nsstest.c @@ -41,7 +41,6 @@ testGetHostByName(const void *opaque) { const struct testNSSData *data =3D opaque; const bool existent =3D data->hostname && data->ipAddr && data->ipAddr= [0]; - int ret =3D -1; struct hostent resolved; char buf[BUF_SIZE] =3D { 0 }; char **addrList; @@ -64,16 +63,16 @@ testGetHostByName(const void *opaque) virReportError(VIR_ERR_INTERNAL_ERROR, "Resolving of %s failed due to internal error", data->hostname); - goto cleanup; + return -1; } else if (rv =3D=3D NSS_STATUS_NOTFOUND) { /* Resolving failed. Should it? */ if (!existent) - ret =3D 0; + return 0; else virReportError(VIR_ERR_INTERNAL_ERROR, "Resolving of %s failed", data->hostname); - goto cleanup; + return -1; } =20 /* Resolving succeeded. Should it? */ @@ -81,7 +80,7 @@ testGetHostByName(const void *opaque) virReportError(VIR_ERR_INTERNAL_ERROR, "Resolving of %s succeeded but was expected to fail= ", data->hostname); - goto cleanup; + return -1; } =20 /* Now lets see if resolved address match our expectations. */ @@ -89,7 +88,7 @@ testGetHostByName(const void *opaque) if (!resolved.h_name) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", "resolved.h_name empty"); - goto cleanup; + return -1; } =20 if (data->af !=3D AF_UNSPEC && @@ -97,7 +96,7 @@ testGetHostByName(const void *opaque) virReportError(VIR_ERR_INTERNAL_ERROR, "Expected AF_INET (%d) got %d", data->af, resolved.h_addrtype); - goto cleanup; + return -1; } =20 if ((resolved.h_addrtype =3D=3D AF_INET && resolved.h_length !=3D 4) || @@ -107,13 +106,13 @@ testGetHostByName(const void *opaque) "Expected %d bytes long address, got %d", resolved.h_addrtype =3D=3D AF_INET ? 4 : 16, resolved.h_length); - goto cleanup; + return -1; } =20 if (!resolved.h_addr_list) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", "resolved.h_addr_list empty"); - goto cleanup; + return -1; } =20 addrList =3D resolved.h_addr_list; @@ -133,7 +132,7 @@ testGetHostByName(const void *opaque) =20 if (!(ipAddr =3D virSocketAddrFormat(&sa))) { /* error reported by helper */ - goto cleanup; + return -1; } =20 if (STRNEQ_NULLABLE(data->ipAddr[i], ipAddr)) { @@ -141,7 +140,7 @@ testGetHostByName(const void *opaque) "Unexpected address %s, expecting %s", ipAddr, NULLSTR(data->ipAddr[i])); VIR_FREE(ipAddr); - goto cleanup; + return -1; } VIR_FREE(ipAddr); =20 @@ -153,12 +152,10 @@ testGetHostByName(const void *opaque) virReportError(VIR_ERR_INTERNAL_ERROR, "Expected %s address, got NULL", data->ipAddr[i]); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 static int diff --git a/tests/nwfilterebiptablestest.c b/tests/nwfilterebiptablestest.c index 61b3284397..97f2ff8ac8 100644 --- a/tests/nwfilterebiptablestest.c +++ b/tests/nwfilterebiptablestest.c @@ -539,8 +539,7 @@ mymain(void) return EXIT_AM_SKIP; } =20 - ret =3D -1; - goto cleanup; + return EXIT_FAILURE; } =20 if (virTestRun("ebiptablesAllTeardown", @@ -578,7 +577,6 @@ mymain(void) NULL) < 0) ret =3D -1; =20 - cleanup: return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 diff --git a/tests/nwfilterxml2firewalltest.c b/tests/nwfilterxml2firewallt= est.c index bef3790da2..84a4656c5b 100644 --- a/tests/nwfilterxml2firewalltest.c +++ b/tests/nwfilterxml2firewalltest.c @@ -328,24 +328,22 @@ static int testSetOneParameter(virHashTablePtr vars, const char *name, const char *value) { - int ret =3D -1; virNWFilterVarValuePtr val; =20 if ((val =3D virHashLookup(vars, name)) =3D=3D NULL) { val =3D virNWFilterVarValueCreateSimpleCopyValue(value); if (!val) - goto cleanup; + return -1; if (virHashUpdateEntry(vars, name, val) < 0) { virNWFilterVarValueFree(val); - goto cleanup; + return -1; } } else { if (virNWFilterVarValueAddValueCopy(val, value) < 0) - goto cleanup; + return -1; } - ret =3D 0; - cleanup: - return ret; + + return 0; } =20 static int testSetDefaultParameters(virHashTablePtr vars) @@ -474,8 +472,7 @@ mymain(void) fprintf(stderr, "iptables/ip6tables/ebtables tools not present= "); return EXIT_AM_SKIP; } - ret =3D -1; - goto cleanup; + return EXIT_FAILURE; } =20 DO_TEST("ah"); @@ -518,7 +515,6 @@ mymain(void) DO_TEST("udplite-ipv6"); DO_TEST("vlan"); =20 - cleanup: return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index 4ff2b38c83..90cbf56408 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -62,17 +62,16 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt, virDomainObjPtr *vm, const char *domxml) { - int ret =3D -1; qemuDomainObjPrivatePtr priv =3D NULL; const unsigned int parseFlags =3D 0; =20 if (!(*vm =3D virDomainObjNew(xmlopt))) - goto cleanup; + return -1; =20 priv =3D (*vm)->privateData; =20 if (!(priv->qemuCaps =3D virQEMUCapsNew())) - goto cleanup; + return -1; =20 virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_VIRTIO_SCSI); virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_USB_STORAGE); @@ -84,31 +83,29 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt, virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE); =20 if (qemuTestCapsCacheInsert(driver.qemuCapsCache, priv->qemuCaps) < 0) - goto cleanup; + return -1; =20 if (!((*vm)->def =3D virDomainDefParseString(domxml, driver.caps, driver.xmlopt, NULL, parseFlags))) - goto cleanup; + return -1; =20 if (qemuDomainAssignAddresses((*vm)->def, priv->qemuCaps, &driver, *vm, true) < 0) { - goto cleanup; + return -1; } =20 if (qemuAssignDeviceAliases((*vm)->def, priv->qemuCaps) < 0) - goto cleanup; + return -1; =20 (*vm)->def->id =3D QEMU_HOTPLUG_TEST_DOMAIN_ID; =20 if (qemuDomainSetPrivatePaths(&driver, *vm) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 static int diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index fd330df3e0..b795075d49 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -365,10 +365,8 @@ testUpdateQEMUCaps(const struct testQemuInfo *info, virDomainObjPtr vm, virCapsPtr caps) { - int ret =3D -1; - if (!caps) - goto cleanup; + return -1; =20 virQEMUCapsSetArch(info->qemuCaps, vm->def->os.arch); =20 @@ -376,17 +374,14 @@ testUpdateQEMUCaps(const struct testQemuInfo *info, =20 if (testAddCPUModels(info->qemuCaps, !!(info->flags & FLAG_SKIP_LEGACY_CPUS)) < 0) - goto cleanup; + return -1; =20 virQEMUCapsInitHostCPUModel(info->qemuCaps, caps->host.arch, VIR_DOMAIN_VIRT_KVM); virQEMUCapsInitHostCPUModel(info->qemuCaps, caps->host.arch, VIR_DOMAIN_VIRT_QEMU); =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 diff --git a/tests/storagebackendsheepdogtest.c b/tests/storagebackendsheep= dogtest.c index a5403e7136..62f3208a91 100644 --- a/tests/storagebackendsheepdogtest.c +++ b/tests/storagebackendsheepdogtest.c @@ -160,11 +160,11 @@ mymain(void) =20 if (virAsprintf(&poolxml, "%s/storagepoolxml2xmlin/pool-sheepdog.xml", abs_srcdir) < 0) - goto cleanup; + return EXIT_SUCCESS; =20 if (virAsprintf(&volxml, "%s/storagevolxml2xmlin/vol-sheepdog.xml", abs_srcdir) < 0) - goto cleanup; + return EXIT_SUCCESS; =20 #define DO_TEST_NODE(collie) \ do { \ @@ -202,7 +202,6 @@ mymain(void) ++test; } =20 - cleanup: return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 diff --git a/tests/virauthconfigtest.c b/tests/virauthconfigtest.c index 42e62cd874..e3bd927dcb 100644 --- a/tests/virauthconfigtest.c +++ b/tests/virauthconfigtest.c @@ -41,7 +41,6 @@ struct ConfigLookupData { =20 static int testAuthLookup(const void *args) { - int ret =3D -1; const struct ConfigLookupData *data =3D args; const char *actual =3D NULL; int rv; @@ -53,7 +52,7 @@ static int testAuthLookup(const void *args) &actual); =20 if (rv < 0) - goto cleanup; + return -1; =20 if (data->expect) { if (!actual || @@ -62,7 +61,7 @@ static int testAuthLookup(const void *args) data->expect, data->hostname, data->service, data->credname, NULLSTR(actual)); - goto cleanup; + return -1; } } else { if (actual) { @@ -70,13 +69,11 @@ static int testAuthLookup(const void *args) data->hostname, data->service, data->credname, actual); - goto cleanup; + return -1; } } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 diff --git a/tests/vircgroupmock.c b/tests/vircgroupmock.c index 7bbaa6dd0f..1b7394232e 100644 --- a/tests/vircgroupmock.c +++ b/tests/vircgroupmock.c @@ -103,7 +103,6 @@ static int make_file(const char *path, =20 static int make_controller_v1(const char *path, mode_t mode) { - int ret =3D -1; const char *controller; =20 if (!STRPREFIX(path, fakesysfscgroupdir)) { @@ -118,12 +117,12 @@ static int make_controller_v1(const char *path, mode_= t mode) return symlink("cpu,cpuacct", path); =20 if (real_mkdir(path, mode) < 0) - goto cleanup; + return -1; =20 # define MAKE_FILE(name, value) \ do { \ if (make_file(path, name, value) < 0) \ - goto cleanup; \ + return -1; \ } while (0) =20 if (STRPREFIX(controller, "cpu,cpuacct")) { @@ -224,14 +223,12 @@ static int make_controller_v1(const char *path, mode_= t mode) =20 } else { errno =3D EINVAL; - goto cleanup; + return -1; } =20 # undef MAKE_FILE =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 diff --git a/tests/virendiantest.c b/tests/virendiantest.c index 7e2eff66dc..38adef9353 100644 --- a/tests/virendiantest.c +++ b/tests/virendiantest.c @@ -30,38 +30,35 @@ test1(const void *data G_GNUC_UNUSED) * unaligned access. */ char array[] =3D { 1, 2, 3, 4, 5, 6, 7, 8, 0x89, 0x8a, 0x8b, 0x8c, 0x8d }; - int ret =3D -1; =20 if (virReadBufInt64BE(array) !=3D 0x0102030405060708ULL) - goto cleanup; + return -1; if (virReadBufInt64BE(array + 5) !=3D 0x060708898a8b8c8dULL) - goto cleanup; + return -1; if (virReadBufInt64LE(array) !=3D 0x0807060504030201ULL) - goto cleanup; + return -1; if (virReadBufInt64LE(array + 5) !=3D 0x8d8c8b8a89080706ULL) - goto cleanup; + return -1; =20 if (virReadBufInt32BE(array) !=3D 0x01020304U) - goto cleanup; + return -1; if (virReadBufInt32BE(array + 9) !=3D 0x8a8b8c8dU) - goto cleanup; + return -1; if (virReadBufInt32LE(array) !=3D 0x04030201U) - goto cleanup; + return -1; if (virReadBufInt32LE(array + 9) !=3D 0x8d8c8b8aU) - goto cleanup; + return -1; =20 if (virReadBufInt16BE(array) !=3D 0x0102U) - goto cleanup; + return -1; if (virReadBufInt16BE(array + 11) !=3D 0x8c8dU) - goto cleanup; + return -1; if (virReadBufInt16LE(array) !=3D 0x0201U) - goto cleanup; + return -1; if (virReadBufInt16LE(array + 11) !=3D 0x8d8cU) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 static int @@ -70,38 +67,35 @@ test2(const void *data G_GNUC_UNUSED) /* Unsigned char should work without cast, even if unaligned access. = */ unsigned char array[] =3D { 1, 2, 3, 4, 5, 6, 7, 8, 0x89, 0x8a, 0x8b, 0x8c, 0x8d }; - int ret =3D -1; =20 if (virReadBufInt64BE(array) !=3D 0x0102030405060708ULL) - goto cleanup; + return -1; if (virReadBufInt64BE(array + 5) !=3D 0x060708898a8b8c8dULL) - goto cleanup; + return -1; if (virReadBufInt64LE(array) !=3D 0x0807060504030201ULL) - goto cleanup; + return -1; if (virReadBufInt64LE(array + 5) !=3D 0x8d8c8b8a89080706ULL) - goto cleanup; + return -1; =20 if (virReadBufInt32BE(array) !=3D 0x01020304U) - goto cleanup; + return -1; if (virReadBufInt32BE(array + 9) !=3D 0x8a8b8c8dU) - goto cleanup; + return -1; if (virReadBufInt32LE(array) !=3D 0x04030201U) - goto cleanup; + return -1; if (virReadBufInt32LE(array + 9) !=3D 0x8d8c8b8aU) - goto cleanup; + return -1; =20 if (virReadBufInt16BE(array) !=3D 0x0102U) - goto cleanup; + return -1; if (virReadBufInt16BE(array + 11) !=3D 0x8c8dU) - goto cleanup; + return -1; if (virReadBufInt16LE(array) !=3D 0x0201U) - goto cleanup; + return -1; if (virReadBufInt16LE(array + 11) !=3D 0x8d8cU) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 static int diff --git a/tests/virkeycodetest.c b/tests/virkeycodetest.c index c2e756cdd0..298409e919 100644 --- a/tests/virkeycodetest.c +++ b/tests/virkeycodetest.c @@ -35,7 +35,6 @@ VIR_LOG_INIT("tests.keycodetest"); =20 static int testKeycodeMapping(const void *data G_GNUC_UNUSED) { - int ret =3D -1; int got; =20 #define TRANSLATE(from, to, val, want) \ @@ -45,7 +44,7 @@ static int testKeycodeMapping(const void *data G_GNUC_UNU= SED) val)) !=3D want) { \ fprintf(stderr, "Translating %d from %s to %s, got %d want %d\= n", \ val, #from, #to, got, want); \ - goto cleanup; \ + return -1; \ } \ } while (0) =20 @@ -60,15 +59,12 @@ static int testKeycodeMapping(const void *data G_GNUC_U= NUSED) =20 #undef TRANSLATE =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 static int testKeycodeStrings(const void *data G_GNUC_UNUSED) { - int ret =3D -1; int got; =20 #define TRANSLATE(from, str, want) \ @@ -77,7 +73,7 @@ static int testKeycodeStrings(const void *data G_GNUC_UNU= SED) str)) !=3D want) { \ fprintf(stderr, "Converting %s from %s, got %d want %d\n", \ str, #from, got, want); \ - goto cleanup; \ + return -1; \ } \ } while (0) =20 @@ -90,9 +86,7 @@ static int testKeycodeStrings(const void *data G_GNUC_UNU= SED) =20 #undef TRANSLATE =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 static int diff --git a/tests/virmacmaptest.c b/tests/virmacmaptest.c index 995aff1178..73b8265a42 100644 --- a/tests/virmacmaptest.c +++ b/tests/virmacmaptest.c @@ -170,8 +170,7 @@ mymain(void) #define DO_TEST_FLUSH_PROLOGUE \ do { \ if (!(mgr =3D virMacMapNew(NULL))) { \ - ret =3D -1; \ - goto cleanup; \ + return EXIT_FAILURE; \ } \ } while (0) =20 @@ -228,7 +227,7 @@ mymain(void) DO_TEST_FLUSH("dom1", "9e:89:49:99:51:0e", "89:b4:3f:08:88:2c", "54:0b= :4c:e2:0a:39"); DO_TEST_FLUSH("dom1", "bb:88:07:19:51:9d", "b7:f1:1a:40:a2:95", "88:94= :39:a3:90:b4"); DO_TEST_FLUSH_EPILOGUE("complex"); - cleanup: + return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 diff --git a/tests/virnetdevtest.c b/tests/virnetdevtest.c index 5d266a28ee..aadbeb1ef4 100644 --- a/tests/virnetdevtest.c +++ b/tests/virnetdevtest.c @@ -35,31 +35,28 @@ struct testVirNetDevGetLinkInfoData { static int testVirNetDevGetLinkInfo(const void *opaque) { - int ret =3D -1; const struct testVirNetDevGetLinkInfoData *data =3D opaque; virNetDevIfLink lnk; =20 if (virNetDevGetLinkInfo(data->ifname, &lnk) < 0) - goto cleanup; + return -1; =20 if (lnk.state !=3D data->state) { fprintf(stderr, "Fetched link state (%s) doesn't match the expected one (%= s)", virNetDevIfStateTypeToString(lnk.state), virNetDevIfStateTypeToString(data->state)); - goto cleanup; + return -1; } =20 if (lnk.speed !=3D data->speed) { fprintf(stderr, "Fetched link speed (%u) doesn't match the expected one (%= u)", lnk.speed, data->speed); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 static int diff --git a/tests/virpcimock.c b/tests/virpcimock.c index d7dc0b00f0..50bd79737d 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -314,7 +314,6 @@ find_fd(int fd, size_t *indx) static int add_fd(int fd, const char *path) { - int ret =3D -1; size_t i; =20 if (find_fd(fd, &i)) { @@ -325,38 +324,34 @@ add_fd(int fd, const char *path) =20 if (VIR_REALLOC_N_QUIET(callbacks, nCallbacks + 1) < 0) { errno =3D ENOMEM; - goto cleanup; + return -1; } =20 callbacks[nCallbacks].path =3D g_strdup(path); callbacks[nCallbacks++].fd =3D fd; - ret =3D 0; - cleanup: - return ret; + + return 0; } =20 static int remove_fd(int fd) { - int ret =3D -1; size_t i; =20 if (find_fd(fd, &i)) { struct fdCallback cb =3D callbacks[i]; =20 if (pci_driver_handle_change(cb.fd, cb.path) < 0) - goto cleanup; + return -1; =20 VIR_FREE(cb.path); if (VIR_DELETE_ELEMENT(callbacks, i, nCallbacks) < 0) { errno =3D EINVAL; - goto cleanup; + return -1; } } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -931,36 +926,30 @@ pci_driver_handle_change(int fd G_GNUC_UNUSED, const = char *path) static int pci_driver_handle_bind(const char *path) { - int ret =3D -1; struct pciDevice *dev =3D pci_device_find_by_content(path); struct pciDriver *driver =3D pci_driver_find_by_path(path); =20 if (!driver || !dev) { /* No driver, no device or failing driver requested */ errno =3D ENODEV; - goto cleanup; + return -1; } =20 - ret =3D pci_driver_bind(driver, dev); - cleanup: - return ret; + return pci_driver_bind(driver, dev); } =20 static int pci_driver_handle_unbind(const char *path) { - int ret =3D -1; struct pciDevice *dev =3D pci_device_find_by_content(path); =20 if (!dev || !dev->driver) { /* No device, device not binded or failing driver requested */ errno =3D ENODEV; - goto cleanup; + return -1; } =20 - ret =3D pci_driver_unbind(dev->driver, dev); - cleanup: - return ret; + return pci_driver_unbind(dev->driver, dev); } =20 =20 diff --git a/tests/virpcitest.c b/tests/virpcitest.c index de2ffc7d41..f9c36d5af8 100644 --- a/tests/virpcitest.c +++ b/tests/virpcitest.c @@ -224,13 +224,12 @@ testVirPCIDeviceIsAssignable(const void *opaque) virPCIDevicePtr dev; =20 if (!(dev =3D virPCIDeviceNew(data->domain, data->bus, data->slot, dat= a->function))) - goto cleanup; + return -1; =20 if (virPCIDeviceIsAssignable(dev, true)) ret =3D 0; =20 virPCIDeviceFree(dev); - cleanup: return ret; } =20 diff --git a/tests/virpolkittest.c b/tests/virpolkittest.c index 97fa877445..fe7a3b5b91 100644 --- a/tests/virpolkittest.c +++ b/tests/virpolkittest.c @@ -145,26 +145,20 @@ VIR_MOCK_WRAP_RET_ARGS(dbus_connection_send_with_repl= y_and_block, =20 static int testPolkitAuthSuccess(const void *opaque G_GNUC_UNUSED) { - int ret =3D -1; - if (virPolkitCheckAuth("org.libvirt.test.success", THE_PID, THE_TIME, THE_UID, NULL, true) < 0) - goto cleanup; - - ret =3D 0; + return -1; =20 - cleanup: - return ret; + return 0; } =20 =20 static int testPolkitAuthDenied(const void *opaque G_GNUC_UNUSED) { - int ret =3D -1; int rv; virErrorPtr err; =20 @@ -177,28 +171,24 @@ static int testPolkitAuthDenied(const void *opaque G_= GNUC_UNUSED) =20 if (rv =3D=3D 0) { fprintf(stderr, "Unexpected auth success\n"); - goto cleanup; + return -1; } else if (rv !=3D -2) { - goto cleanup; + return -1; } =20 err =3D virGetLastError(); if (!err || !strstr(err->message, _("access denied by policy"))) { fprintf(stderr, "Incorrect error response\n"); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 static int testPolkitAuthChallenge(const void *opaque G_GNUC_UNUSED) { - int ret =3D -1; int rv; virErrorPtr err; =20 @@ -211,9 +201,9 @@ static int testPolkitAuthChallenge(const void *opaque G= _GNUC_UNUSED) =20 if (rv =3D=3D 0) { fprintf(stderr, "Unexpected auth success\n"); - goto cleanup; + return -1; } else if (rv !=3D -2) { - goto cleanup; + return -1; } =20 err =3D virGetLastError(); @@ -221,19 +211,15 @@ static int testPolkitAuthChallenge(const void *opaque= G_GNUC_UNUSED) err->code !=3D VIR_ERR_AUTH_UNAVAILABLE || !strstr(err->message, _("no polkit agent available to authenticate= "))) { fprintf(stderr, "Incorrect error response\n"); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 static int testPolkitAuthCancelled(const void *opaque G_GNUC_UNUSED) { - int ret =3D -1; int rv; virErrorPtr err; =20 @@ -246,28 +232,24 @@ static int testPolkitAuthCancelled(const void *opaque= G_GNUC_UNUSED) =20 if (rv =3D=3D 0) { fprintf(stderr, "Unexpected auth success\n"); - goto cleanup; + return -1; } else if (rv !=3D -2) { - goto cleanup; + return -1; } =20 err =3D virGetLastError(); if (!err || !strstr(err->message, _("user cancelled authentication process"))) { fprintf(stderr, "Incorrect error response\n"); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 static int testPolkitAuthDetailsSuccess(const void *opaque G_GNUC_UNUSED) { - int ret =3D -1; const char *details[] =3D { "org.libvirt.test.person", "Fred", NULL, @@ -279,18 +261,14 @@ static int testPolkitAuthDetailsSuccess(const void *o= paque G_GNUC_UNUSED) THE_UID, details, true) < 0) - goto cleanup; - - ret =3D 0; + return -1; =20 - cleanup: - return ret; + return 0; } =20 =20 static int testPolkitAuthDetailsDenied(const void *opaque G_GNUC_UNUSED) { - int ret =3D -1; int rv; virErrorPtr err; const char *details[] =3D { @@ -307,22 +285,19 @@ static int testPolkitAuthDetailsDenied(const void *op= aque G_GNUC_UNUSED) =20 if (rv =3D=3D 0) { fprintf(stderr, "Unexpected auth success\n"); - goto cleanup; + return -1; } else if (rv !=3D -2) { - goto cleanup; + return -1; } =20 err =3D virGetLastError(); if (!err || !strstr(err->message, _("access denied by policy"))) { fprintf(stderr, "Incorrect error response\n"); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 diff --git a/tests/virstringtest.c b/tests/virstringtest.c index 1e408f2757..fc5f9bf937 100644 --- a/tests/virstringtest.c +++ b/tests/virstringtest.c @@ -39,7 +39,6 @@ struct testStreqData { static int testStreq(const void *args) { const struct testStreqData *data =3D args; - int ret =3D -1; bool equal =3D true; bool streq_rv, strneq_rv; size_t i; @@ -63,19 +62,17 @@ static int testStreq(const void *args) virFilePrintf(stderr, "STREQ not working correctly. Expected %d got %d", (int) equal, (int) streq_rv); - goto cleanup; + return -1; } =20 if (strneq_rv =3D=3D equal) { virFilePrintf(stderr, "STRNEQ not working correctly. Expected %d got %d", (int) equal, (int) strneq_rv); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 struct testSplitData { @@ -381,7 +378,6 @@ testStringSortCompare(const void *opaque G_GNUC_UNUSED) const char *sortrlist[] =3D { "turducken", "tasty", "goat", "chicken", "astro", }; - int ret =3D -1; size_t i; =20 qsort(randlist, G_N_ELEMENTS(randlist), sizeof(randlist[0]), @@ -393,18 +389,16 @@ testStringSortCompare(const void *opaque G_GNUC_UNUSE= D) if (STRNEQ(randlist[i], sortlist[i])) { fprintf(stderr, "sortlist[%zu] '%s' !=3D randlist[%zu] '%s'\n", i, sortlist[i], i, randlist[i]); - goto cleanup; + return -1; } if (STRNEQ(randrlist[i], sortrlist[i])) { fprintf(stderr, "sortrlist[%zu] '%s' !=3D randrlist[%zu] '%s'\= n", i, sortrlist[i], i, randrlist[i]); - goto cleanup; + return -1; } } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list