]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: vir: remove pointless labels
authorJán Tomko <jtomko@redhat.com>
Sat, 4 Sep 2021 20:41:36 +0000 (22:41 +0200)
committerJán Tomko <jtomko@redhat.com>
Thu, 9 Sep 2021 16:06:13 +0000 (18:06 +0200)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
15 files changed:
tests/vircapstest.c
tests/virconftest.c
tests/vircryptotest.c
tests/virfiletest.c
tests/virhostcputest.c
tests/viriscsitest.c
tests/virkmodtest.c
tests/virmacmaptest.c
tests/virnetworkportxml2xmltest.c
tests/virnumamock.c
tests/virpcitest.c
tests/virresctrltest.c
tests/virscsitest.c
tests/virstringtest.c
tests/virsystemdtest.c

index ebabbbb9a09a721658fc1d5b8763999e3181f38a..d1b50338441535a689e3fea3d0cbfb15029e9e65 100644 (file)
@@ -153,10 +153,8 @@ test_virCapsDomainDataLookupQEMU(const void *data G_GNUC_UNUSED)
     int ret = 0;
     g_autoptr(virCaps) caps = NULL;
 
-    if (!(caps = testQemuCapsInit())) {
-        ret = -1;
-        goto out;
-    }
+    if (!(caps = testQemuCapsInit()))
+        return -1;
 
     /* 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_GNUC_UNUSED)
         "/usr/bin/qemu-system-aarch64", "pc");
     CAPS_EXPECT_ERR(-1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_VMWARE, NULL, "pc");
 
- out:
     return ret;
 }
 #endif /* WITH_QEMU */
@@ -207,10 +204,8 @@ test_virCapsDomainDataLookupLXC(const void *data G_GNUC_UNUSED)
     int ret = 0;
     g_autoptr(virCaps) caps = NULL;
 
-    if (!(caps = testLXCCapsInit())) {
-        ret = -1;
-        goto out;
-    }
+    if (!(caps = testLXCCapsInit()))
+        return -1;
 
     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);
 
- out:
     return ret;
 }
 #endif /* WITH_LXC */
index a7189579d3bd54f6b9d52404e7488493f362be22..5d1ad8a61272344954c171907e5ad08ebfbe26bc 100644 (file)
@@ -67,7 +67,6 @@ static int testConfMemoryNoNewline(const void *opaque G_GNUC_UNUSED)
         "uint = 12345";
 
     g_autoptr(virConf) conf = virConfReadString(srcdata, 0);
-    int ret = -1;
     virConfValue *val;
     unsigned long long llvalue;
     g_autofree char *str = NULL;
@@ -77,49 +76,47 @@ static int testConfMemoryNoNewline(const void *opaque G_GNUC_UNUSED)
         return -1;
 
     if (!(val = virConfGetValue(conf, "ullong")))
-        goto cleanup;
+        return -1;
 
     if (val->type != VIR_CONF_STRING)
-        goto cleanup;
+        return -1;
 
     if (virStrToLong_ull(val->str, NULL, 10, &llvalue) < 0)
-        goto cleanup;
+        return -1;
 
     if (llvalue != 123456789) {
         fprintf(stderr, "Expected '123' got '%llu'\n", llvalue);
-        goto cleanup;
+        return -1;
     }
 
     if (virConfGetValueType(conf, "string") !=
         VIR_CONF_STRING) {
         fprintf(stderr, "expected a string for 'string'\n");
-        goto cleanup;
+        return -1;
     }
 
     if (virConfGetValueString(conf, "string", &str) < 0)
-        goto cleanup;
+        return -1;
 
     if (STRNEQ_NULLABLE(str, "foo")) {
         fprintf(stderr, "Expected 'foo' got '%s'\n", str);
-        goto cleanup;
+        return -1;
     }
 
     if (virConfGetValueType(conf, "uint") != VIR_CONF_ULLONG) {
         fprintf(stderr, "expected an unsigned long for 'uint'\n");
-        goto cleanup;
+        return -1;
     }
 
     if (virConfGetValueInt(conf, "uint", &uintvalue) < 0)
-        goto cleanup;
+        return -1;
 
     if (uintvalue != 12345) {
         fprintf(stderr, "Expected 12345 got %ud\n", uintvalue);
-        goto cleanup;
+        return -1;
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -338,7 +335,6 @@ static int testConfParseString(const void *opaque G_GNUC_UNUSED)
         "int = 6963472309248\n" \
         "string = \"foo\"\n";
 
-    int ret = -1;
     g_autoptr(virConf) conf = virConfReadString(srcdata, 0);
     g_autofree char *str = NULL;
 
@@ -348,25 +344,23 @@ static int testConfParseString(const void *opaque G_GNUC_UNUSED)
     if (virConfGetValueType(conf, "string") !=
         VIR_CONF_STRING) {
         fprintf(stderr, "expected a string for 'string'\n");
-        goto cleanup;
+        return -1;
     }
 
     if (virConfGetValueString(conf, "string", &str) < 0)
-        goto cleanup;
+        return -1;
 
     if (STRNEQ_NULLABLE(str, "foo")) {
         fprintf(stderr, "Expected 'foo' got '%s'\n", str);
-        goto cleanup;
+        return -1;
     }
 
     if (virConfGetValueString(conf, "int", &str) != -1) {
         fprintf(stderr, "Expected error for 'int'\n");
-        goto cleanup;
+        return -1;
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
index 2d503a439ee1158bc05049bcea9847d393bd560d..98af4761564f38bd0f4f7a7fe4979b808ebe3d59 100644 (file)
@@ -38,22 +38,19 @@ testCryptoHash(const void *opaque)
 {
     const struct testCryptoHashData *data = opaque;
     g_autofree char *actual = NULL;
-    int ret = -1;
 
     if (virCryptoHashString(data->hash, data->input, &actual) < 0) {
         fprintf(stderr, "Failed to generate crypto hash\n");
-        goto cleanup;
+        return -1;
     }
 
     if (STRNEQ_NULLABLE(data->output, actual)) {
         fprintf(stderr, "Expected hash '%s' but got '%s'\n",
                 data->output, NULLSTR(actual));
-        goto cleanup;
+        return -1;
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -75,7 +72,6 @@ testCryptoEncrypt(const void *opaque)
     size_t ivlen = 16;
     g_autofree uint8_t *ciphertext = NULL;
     size_t ciphertextlen = 0;
-    int ret = -1;
 
     if (!virCryptoHaveCipher(data->algorithm)) {
         fprintf(stderr, "cipher algorithm=%d unavailable\n", data->algorithm);
@@ -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;
     }
 
     if (virCryptoEncryptData(data->algorithm, enckey, enckeylen, iv, ivlen,
                              data->input, data->inputlen,
                              &ciphertext, &ciphertextlen) < 0)
-        goto cleanup;
+        return -1;
 
     if (data->ciphertextlen != ciphertextlen) {
         fprintf(stderr, "Expected ciphertextlen(%zu) doesn't match (%zu)\n",
                 data->ciphertextlen, ciphertextlen);
-        goto cleanup;
+        return -1;
     }
 
     if (memcmp(data->ciphertext, ciphertext, ciphertextlen)) {
         fprintf(stderr, "Expected ciphertext doesn't match\n");
-        goto cleanup;
+        return -1;
     }
 
-    ret = 0;
- cleanup:
-
-    return ret;
+    return 0;
 }
 
 
index a6e722b4d2889ca586a5b5969e682893d5644097..1434d6b7ba7758a86656645297844d88ac9309c0 100644 (file)
@@ -103,7 +103,6 @@ static int
 testFileSanitizePath(const void *opaque)
 {
     const struct testFileSanitizePathData *data = opaque;
-    int ret = -1;
     g_autofree char *actual = NULL;
 
     if (!(actual = virFileSanitizePath(data->path)))
@@ -111,13 +110,10 @@ testFileSanitizePath(const void *opaque)
 
     if (STRNEQ(actual, data->expect)) {
         fprintf(stderr, "\nexpect: '%s'\nactual: '%s'\n", data->expect, actual);
-        goto cleanup;
+        return -1;
     }
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -195,41 +191,38 @@ holesSupported(void)
     off_t offsets[] = {EXTENT, EXTENT, EXTENT, -1};
     off_t tmp;
     VIR_AUTOCLOSE fd = -1;
-    bool ret = false;
 
     if ((fd = makeSparseFile(offsets, true)) < 0)
-        goto cleanup;
+        return false;
 
     /* The way this works is: there are 4K of data followed by 4K hole followed
      * by 4K hole again. Check if the filesystem we are running the test suite
      * on supports holes. */
     if ((tmp = lseek(fd, 0, SEEK_DATA)) == (off_t) -1)
-        goto cleanup;
+        return false;
 
     if (tmp != 0)
-        goto cleanup;
+        return false;
 
     if ((tmp = lseek(fd, tmp, SEEK_HOLE)) == (off_t) -1)
-        goto cleanup;
+        return false;
 
     if (tmp != EXTENT * 1024)
-        goto cleanup;
+        return false;
 
     if ((tmp = lseek(fd, tmp, SEEK_DATA)) == (off_t) -1)
-        goto cleanup;
+        return false;
 
     if (tmp != 2 * EXTENT * 1024)
-        goto cleanup;
+        return false;
 
     if ((tmp = lseek(fd, tmp, SEEK_HOLE)) == (off_t) -1)
-        goto cleanup;
+        return false;
 
     if (tmp != 3 * EXTENT * 1024)
-        goto cleanup;
+        return false;
 
-    ret = true;
- cleanup:
-    return ret;
+    return true;
 }
 
 #else /* !WITH_DECL_SEEK_HOLE || !defined(__linux__)*/
@@ -261,11 +254,10 @@ testFileInData(const void *opaque)
 {
     const struct testFileInData *data = opaque;
     VIR_AUTOCLOSE fd = -1;
-    int ret = -1;
     size_t i;
 
     if ((fd = makeSparseFile(data->offsets, data->startData)) < 0)
-        goto cleanup;
+        return -1;
 
     for (i = 0; data->offsets[i] != (off_t) -1; i++) {
         bool shouldInData = data->startData;
@@ -277,32 +269,29 @@ testFileInData(const void *opaque)
             shouldInData = !shouldInData;
 
         if (virFileInData(fd, &realInData, &realLen) < 0)
-            goto cleanup;
+            return -1;
 
         if (realInData != shouldInData) {
             fprintf(stderr, "Unexpected data/hole. Expected %s got %s\n",
                     shouldInData ? "data" : "hole",
                     realInData ? "data" : "hole");
-            goto cleanup;
+            return -1;
         }
 
         shouldLen = data->offsets[i] * 1024;
         if (realLen != shouldLen) {
             fprintf(stderr, "Unexpected section length. Expected %lld got %lld\n",
                     shouldLen, realLen);
-            goto cleanup;
+            return -1;
         }
 
         if (lseek(fd, shouldLen, SEEK_CUR) < 0) {
             fprintf(stderr, "Unable to seek\n");
-            goto cleanup;
+            return -1;
         }
     }
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
index c80cd1581c56cf5bc6e67731904420549f815114..746e65727f61ab8b454a4c62e5554ae43bed3c4a 100644 (file)
@@ -30,7 +30,6 @@ linuxTestCompareFiles(const char *cpuinfofile,
                       virArch arch,
                       const char *outputfile)
 {
-    int ret = -1;
     g_autofree char *actualData = NULL;
     virNodeInfo nodeinfo;
     g_autoptr(FILE) cpuinfo = 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;
     }
 
     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;
     }
 
     actualData = g_strdup_printf("CPUs: %u/%u, MHz: %u, Nodes: %u, Sockets: %u, "
@@ -61,12 +60,9 @@ linuxTestCompareFiles(const char *cpuinfofile,
                                  nodeinfo.cores, nodeinfo.threads);
 
     if (virTestCompareToFile(actualData, outputfile) < 0)
-        goto fail;
-
-    ret = 0;
+        return -1;
 
- fail:
-    return ret;
+    return 0;
 }
 
 
index 7ea761fda6bf1f4915954b0de1c4941949b0d765..f2539e47b0022b3d348ec5122ec46de09eb6a054 100644 (file)
@@ -211,7 +211,6 @@ testISCSIGetSession(const void *data)
     const struct testSessionInfo *info = data;
     struct testIscsiadmCbData cbData = { 0 };
     g_autofree char *actual_session = NULL;
-    int ret = -1;
     g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
 
     cbData.output_version = 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;
     }
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 struct testScanTargetsInfo {
@@ -295,17 +291,14 @@ testISCSIConnectionLogin(const void *data)
 {
     const struct testConnectionInfoLogin *info = data;
     struct testIscsiadmCbData cbData = { 0 };
-    int ret = -1;
     g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
 
     virCommandSetDryRun(dryRunToken, NULL, false, false, testIscsiadmCb, &cbData);
 
     if (virISCSIConnectionLogin(info->portal, info->initiatoriqn, info->target) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
index 2f07757c8887bac5765457db628f6f49da943fd5..d2df3bdb042bc2b3c53a2439f9f8fcf4bbd2a679 100644 (file)
 static int
 checkOutput(virBuffer *buf, const char *exp_cmd)
 {
-    int ret = -1;
     g_autofree char *actual_cmd = NULL;
 
     if (!(actual_cmd = virBufferContentAndReset(buf))) {
         fprintf(stderr, "cannot compare buffer to exp: %s", exp_cmd);
-        goto cleanup;
+        return -1;
     }
 
     if (STRNEQ(exp_cmd, actual_cmd)) {
         virTestDifference(stderr, exp_cmd, actual_cmd);
-        goto cleanup;
+        return -1;
     }
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
 static int
 testKModLoad(const void *args G_GNUC_UNUSED)
 {
-    int ret = -1;
     g_autofree char *errbuf = NULL;
     g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
     g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
@@ -67,23 +62,19 @@ testKModLoad(const void *args G_GNUC_UNUSED)
     errbuf = virKModLoad(MODNAME);
     if (errbuf) {
         fprintf(stderr, "Failed to load, error: %s\n", errbuf);
-        goto cleanup;
+        return -1;
     }
 
     if (checkOutput(&buf, MODPROBE " -b " MODNAME "\n") < 0)
-        goto cleanup;
-
-    ret = 0;
+        return -1;
 
- cleanup:
-    return ret;
+    return 0;
 }
 
 
 static int
 testKModUnload(const void *args G_GNUC_UNUSED)
 {
-    int ret = -1;
     g_autofree char *errbuf = NULL;
     g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
     g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
@@ -93,16 +84,13 @@ testKModUnload(const void *args G_GNUC_UNUSED)
     errbuf = virKModUnload(MODNAME);
     if (errbuf) {
         fprintf(stderr, "Failed to unload, error: %s\n", errbuf);
-        goto cleanup;
+        return -1;
     }
 
     if (checkOutput(&buf, RMMOD " " MODNAME "\n") < 0)
-        goto cleanup;
-
-    ret = 0;
+        return -1;
 
- cleanup:
-    return ret;
+    return 0;
 }
 
 
index 01a3588ed9a8c75ecf451c673d6757d7dd45388f..9a28c1bed00c953a55cdb95a129bc823df8f3803 100644 (file)
@@ -40,12 +40,11 @@ testMACLookup(const void *opaque)
     GSList *next;
     size_t i, j;
     g_autofree char *file = NULL;
-    int ret = -1;
 
     file = g_strdup_printf("%s/virmacmaptestdata/%s.json", abs_srcdir, data->file);
 
     if (!(mgr = virMacMapNew(file)))
-        goto cleanup;
+        return -1;
 
     macs = virMacMapLookup(mgr, data->domain);
 
@@ -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;
         }
     }
 
@@ -72,13 +71,11 @@ testMACLookup(const void *opaque)
         if (!next) {
             fprintf(stderr,
                     "Expected %s in the returned list of MACs\n", data->macs[i]);
-            goto cleanup;
+            return -1;
         }
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -90,18 +87,17 @@ testMACRemove(const void *opaque)
     GSList *macs;
     size_t i;
     g_autofree char *file = NULL;
-    int ret = -1;
 
     file = g_strdup_printf("%s/virmacmaptestdata/%s.json", abs_srcdir, data->file);
 
     if (!(mgr = virMacMapNew(file)))
-        goto cleanup;
+        return -1;
 
     for (i = 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;
         }
     }
 
@@ -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;
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -124,19 +118,16 @@ testMACFlush(const void *opaque)
     const struct testData *data = opaque;
     g_autofree char *file = NULL;
     g_autofree char *str = NULL;
-    int ret = -1;
 
     file = g_strdup_printf("%s/virmacmaptestdata/%s.json", abs_srcdir, data->file);
 
     if (virMacMapDumpStr(data->mgr, &str) < 0)
-        goto cleanup;
+        return -1;
 
     if (virTestCompareToFile(str, file) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
index 8d29db724fc43f857f3b73b069f8ce06d32cbbf8..093d855633e58900a75de317a4a76cdd44613513 100644 (file)
@@ -37,21 +37,18 @@ static int
 testCompareXMLToXMLFiles(const char *expected)
 {
     g_autofree char *actual = NULL;
-    int ret = -1;
     g_autoptr(virNetworkPortDef) dev = NULL;
 
     if (!(dev = virNetworkPortDefParseFile(expected)))
-        goto cleanup;
+        return -1;
 
     if (!(actual = virNetworkPortDefFormat(dev)))
-        goto cleanup;
+        return -1;
 
     if (virTestCompareToFile(actual, expected) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 struct testInfo {
@@ -62,14 +59,12 @@ static int
 testCompareXMLToXMLHelper(const void *data)
 {
     const struct testInfo *info = data;
-    int ret = -1;
     g_autofree char *xml = NULL;
 
     xml = g_strdup_printf("%s/virnetworkportxml2xmldata/%s.xml", abs_srcdir,
                           info->name);
 
-    ret = testCompareXMLToXMLFiles(xml);
-    return ret;
+    return testCompareXMLToXMLFiles(xml);
 }
 
 static int
index 6e0293a49edf133404271fa827da9974b68c6081..19c26d1e375f0aed0e3231f84d72972b7d803e4b 100644 (file)
@@ -162,7 +162,6 @@ virNumaGetPages(int node,
 int
 virNumaGetNodeCPUs(int node, virBitmap **cpus)
 {
-    int ret = -1;
     g_autofree char *cpulist = NULL;
 
     if (virFileReadValueString(&cpulist,
@@ -177,9 +176,7 @@ virNumaGetNodeCPUs(int node, virBitmap **cpus)
         *cpus = virBitmapParseUnlimited(cpulist);
     }
     if (!*cpus)
-        goto cleanup;
+        return -1;
 
-    ret = virBitmapCountBits(*cpus);
- cleanup:
-    return ret;
+    return virBitmapCountBits(*cpus);
 }
index 1ff0330b2245a252eae8c7209ca5531dbb65bb0d..6fe9b7d13a60d940a2216e0ef53dc49a1a77c8f8 100644 (file)
@@ -34,22 +34,19 @@ testVirPCIDeviceCheckDriver(virPCIDevice *dev, const char *expected)
 {
     g_autofree char *path = NULL;
     g_autofree char *driver = NULL;
-    int ret = -1;
 
     if (virPCIDeviceGetDriverPathAndName(dev, &path, &driver) < 0)
-        goto cleanup;
+        return -1;
 
     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;
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 static int
index 0beb9a4df455768b6341bf741e563b6ad543e542..c5733a7972322a527bd9f95525f4677222821a39 100644 (file)
@@ -20,7 +20,6 @@ test_virResctrlGetUnused(const void *opaque)
     struct virResctrlData *data = (struct virResctrlData *) opaque;
     g_autofree char *system_dir = NULL;
     g_autofree char *resctrl_dir = NULL;
-    int ret = -1;
     g_autoptr(virResctrlAlloc) alloc = NULL;
     g_autofree char *schemata_str = NULL;
     g_autofree char *schemata_file = NULL;
@@ -41,7 +40,7 @@ test_virResctrlGetUnused(const void *opaque)
     caps = virCapabilitiesNew(VIR_ARCH_X86_64, false, false);
     if (!caps || virCapabilitiesInitCaches(caps) < 0) {
         fprintf(stderr, "Could not initialize capabilities");
-        goto cleanup;
+        return -1;
     }
 
     alloc = virResctrlAllocGetUnused(caps->host.resctrl);
@@ -50,22 +49,19 @@ test_virResctrlGetUnused(const void *opaque)
 
     if (!alloc) {
         if (data->fail)
-            ret = 0;
-        goto cleanup;
+            return 0;
+        return -1;
     } else if (data->fail) {
         VIR_TEST_DEBUG("Error expected but there wasn't any.");
-        ret = -1;
-        goto cleanup;
+        return -1;
     }
 
     schemata_str = virResctrlAllocFormat(alloc);
 
     if (virTestCompareToFile(schemata_str, schemata_file) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
index d67cd238963b62f1f44e19103ebdfb169b9f80ca..c96699e15744c19f7931148f2ceb08b300d003be 100644 (file)
@@ -37,18 +37,15 @@ static int
 test1(const void *data G_GNUC_UNUSED)
 {
     g_autofree char *name = NULL;
-    int ret = -1;
 
     if (!(name = virSCSIDeviceGetDevName(virscsi_prefix,
                                          "scsi_host1", 0, 0, 0)))
         return -1;
 
     if (STRNEQ(name, "sdh"))
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 /*
@@ -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_name)
 {
-    int ret = -1;
     g_autofree char *src_path = NULL;
     g_autofree char *dst_path = NULL;
 
@@ -171,13 +167,10 @@ create_symlink(const char *tmpdir, const char *src_name, const char *dst_name)
 
     if (symlink(src_path, dst_path) < 0) {
         VIR_WARN("Failed to create symlink '%s' to '%s'", src_path, dst_path);
-        goto cleanup;
+        return -1;
     }
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 static int
index bbdd17da8428f2f8a068cf835048d4f9aa390df7..277deca934771de3eff5e4ba270ceb5d11fa33ac 100644 (file)
@@ -223,7 +223,6 @@ testStringReplace(const void *opaque G_GNUC_UNUSED)
 {
     const struct stringReplaceData *data = opaque;
     g_autofree char *result = NULL;
-    int ret = -1;
 
     result = 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;
     }
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -400,7 +396,6 @@ struct testStripData {
 static int testStripIPv6Brackets(const void *args)
 {
     const struct testStripData *data = args;
-    int ret = -1;
     g_autofree char *res = NULL;
 
     res = 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;
     }
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 static int testStripControlChars(const void *args)
 {
     const struct testStripData *data = args;
-    int ret = -1;
     g_autofree char *res = NULL;
 
     res = 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;
     }
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 struct testFilterData {
@@ -450,7 +438,6 @@ struct testFilterData {
 static int testFilterChars(const void *args)
 {
     const struct testFilterData *data = args;
-    int ret = -1;
     g_autofree char *res = NULL;
 
     res = 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;
     }
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 static int
index 9cf6bfec43aa82b830e90e051cf32f775edbbff9..9a063dd1fc6a561486dddd565a02480d726bef7c 100644 (file)
@@ -369,45 +369,37 @@ static int
 testScopeName(const void *opaque)
 {
     const struct testNameData *data = opaque;
-    int ret = -1;
     g_autofree char *actual = NULL;
 
     if (!(actual = virSystemdMakeScopeName(data->name, "lxc", data->legacy)))
-        goto cleanup;
+        return -1;
 
     if (STRNEQ(actual, data->expected)) {
         fprintf(stderr, "Expected '%s' but got '%s'\n",
                 data->expected, actual);
-        goto cleanup;
+        return -1;
     }
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 static int
 testMachineName(const void *opaque)
 {
     const struct testNameData *data = opaque;
-    int ret = -1;
     g_autofree char *actual = NULL;
 
     if (!(actual = virDomainDriverGenerateMachineName("qemu", data->root,
                                                       data->id, data->name, true)))
-        goto cleanup;
+        return -1;
 
     if (STRNEQ(actual, data->expected)) {
         fprintf(stderr, "Expected '%s' but got '%s'\n",
                 data->expected, actual);
-        goto cleanup;
+        return -1;
     }
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 typedef int (*virSystemdCanHelper)(bool * result);