]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: remove unneeded cleanup labels
authorDaniel Henrique Barboza <danielhb413@gmail.com>
Tue, 12 Nov 2019 20:46:29 +0000 (17:46 -0300)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 19 Nov 2019 14:22:43 +0000 (15:22 +0100)
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
17 files changed:
tests/commandtest.c
tests/networkxml2firewalltest.c
tests/nsstest.c
tests/nwfilterebiptablestest.c
tests/nwfilterxml2firewalltest.c
tests/qemuhotplugtest.c
tests/qemuxml2argvtest.c
tests/virauthconfigtest.c
tests/vircgroupmock.c
tests/virendiantest.c
tests/virkeycodetest.c
tests/virmacmaptest.c
tests/virnetdevtest.c
tests/virpcimock.c
tests/virpcitest.c
tests/virpolkittest.c
tests/virstringtest.c

index a8686f777f4981422f34951f758450dc817de5b5..5df1aa4221d45ec71aec5358853e0a4db555e851 100644 (file)
@@ -943,12 +943,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 = -1;
     int status = -1;
     pid_t pid;
 
     if ((pid = virFork()) < 0)
-        goto cleanup;
+        return -1;
     if (pid == 0) {
         if ((pid = virFork()) < 0)
             _exit(EXIT_FAILURE);
@@ -961,14 +960,14 @@ test23(const void *unused G_GNUC_UNUSED)
     }
 
     if (virProcessWait(pid, &status, true) < 0)
-        goto cleanup;
+        return -1;
     if (!WIFEXITED(status) || WEXITSTATUS(status) != 42) {
         printf("Unexpected status %d\n", status);
-        goto cleanup;
+        return -1;
     }
 
     if ((pid = virFork()) < 0)
-        goto cleanup;
+        return -1;
     if (pid == 0) {
         if ((pid = virFork()) < 0)
             _exit(EXIT_FAILURE);
@@ -983,15 +982,13 @@ test23(const void *unused G_GNUC_UNUSED)
     }
 
     if (virProcessWait(pid, &status, true) < 0)
-        goto cleanup;
+        return -1;
     if (!WIFSIGNALED(status) || WTERMSIG(status) != SIGKILL) {
         printf("Unexpected status %d\n", status);
-        goto cleanup;
+        return -1;
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 static int test25(const void *unused G_GNUC_UNUSED)
index 93c232f3bdca73e15bc7ccc61072c00ba959821c..0ad5e2303b324bd452d959db9ae5e76446382325 100644 (file)
@@ -160,16 +160,13 @@ mymain(void)
             return EXIT_AM_SKIP;
         }
 
-        ret = -1;
-        goto cleanup;
+        return EXIT_FAILURE;
     }
 
     basefile = g_strdup_printf("%s/networkxml2firewalldata/base.args", abs_srcdir);
 
-    if (virTestLoadFile(basefile, &baseargs) < 0) {
-        ret = -1;
-        goto cleanup;
-    }
+    if (virTestLoadFile(basefile, &baseargs) < 0)
+        return EXIT_FAILURE;
 
     DO_TEST("nat-default");
     DO_TEST("nat-tftp");
@@ -178,7 +175,6 @@ mymain(void)
     DO_TEST("nat-ipv6");
     DO_TEST("route-default");
 
- cleanup:
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
index 734e4cbc0769ee0c908bcb09e61599753b7bd4ef..d146100747031d4750657b9c33ad371785f8f4aa 100644 (file)
@@ -41,7 +41,6 @@ testGetHostByName(const void *opaque)
 {
     const struct testNSSData *data = opaque;
     const bool existent = data->hostname && data->ipAddr && data->ipAddr[0];
-    int ret = -1;
     struct hostent resolved;
     char buf[BUF_SIZE] = { 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 == NSS_STATUS_NOTFOUND) {
         /* Resolving failed. Should it? */
         if (!existent)
-            ret = 0;
+            return 0;
         else
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            "Resolving of %s failed",
                            data->hostname);
-        goto cleanup;
+        return -1;
     }
 
     /* 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;
     }
 
     /* 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;
     }
 
     if (data->af != 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;
     }
 
     if ((resolved.h_addrtype == AF_INET && resolved.h_length != 4) ||
@@ -107,13 +106,13 @@ testGetHostByName(const void *opaque)
                        "Expected %d bytes long address, got %d",
                        resolved.h_addrtype == AF_INET ? 4 : 16,
                        resolved.h_length);
-        goto cleanup;
+        return -1;
     }
 
     if (!resolved.h_addr_list) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        "resolved.h_addr_list empty");
-        goto cleanup;
+        return -1;
     }
 
     addrList = resolved.h_addr_list;
@@ -133,7 +132,7 @@ testGetHostByName(const void *opaque)
 
         if (!(ipAddr = virSocketAddrFormat(&sa))) {
             /* error reported by helper */
-            goto cleanup;
+            return -1;
         }
 
         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);
 
@@ -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;
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 static int
index f7fb03396d62364e323a448d1e3cb44c7d86bef0..3e6c335d4e088f5513ffce6497e30bc3ff835683 100644 (file)
@@ -518,8 +518,7 @@ mymain(void)
             return EXIT_AM_SKIP;
         }
 
-        ret = -1;
-        goto cleanup;
+        return EXIT_FAILURE;
     }
 
     if (virTestRun("ebiptablesAllTeardown",
@@ -557,7 +556,6 @@ mymain(void)
                    NULL) < 0)
         ret = -1;
 
- cleanup:
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
index ff12c5de7610dd9cae9f357823d0a310e8468af6..da86ec9463e8642b089725a28162471b9ad62e72 100644 (file)
@@ -327,24 +327,22 @@ static int testSetOneParameter(virHashTablePtr vars,
                                const char *name,
                                const char *value)
 {
-    int ret = -1;
     virNWFilterVarValuePtr val;
 
     if ((val = virHashLookup(vars, name)) == NULL) {
         val = 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 = 0;
- cleanup:
-    return ret;
+
+    return 0;
 }
 
 static int testSetDefaultParameters(virHashTablePtr vars)
@@ -468,8 +466,7 @@ mymain(void)
             fprintf(stderr, "iptables/ip6tables/ebtables tools not present");
             return EXIT_AM_SKIP;
         }
-        ret = -1;
-        goto cleanup;
+        return EXIT_FAILURE;
     }
 
     DO_TEST("ah");
@@ -512,7 +509,6 @@ mymain(void)
     DO_TEST("udplite-ipv6");
     DO_TEST("vlan");
 
- cleanup:
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
index 7d70113b6ebf9e3a5d14dc7771ba6bc17d9ff53b..7278a6a6baa967f68765bba9427486f5cb1c996e 100644 (file)
@@ -60,17 +60,16 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt,
                          virDomainObjPtr *vm,
                          const char *domxml)
 {
-    int ret = -1;
     qemuDomainObjPrivatePtr priv = NULL;
     const unsigned int parseFlags = 0;
 
     if (!(*vm = virDomainObjNew(xmlopt)))
-        goto cleanup;
+        return -1;
 
     priv = (*vm)->privateData;
 
     if (!(priv->qemuCaps = virQEMUCapsNew()))
-        goto cleanup;
+        return -1;
 
     virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_VIRTIO_SCSI);
     virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_USB_STORAGE);
@@ -85,31 +84,29 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt,
     virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_CIRRUS_VGA);
 
     if (qemuTestCapsCacheInsert(driver.qemuCapsCache, priv->qemuCaps) < 0)
-        goto cleanup;
+        return -1;
 
     if (!((*vm)->def = virDomainDefParseString(domxml,
                                                driver.caps,
                                                driver.xmlopt,
                                                NULL,
                                                parseFlags)))
-        goto cleanup;
+        return -1;
 
     if (qemuDomainAssignAddresses((*vm)->def, priv->qemuCaps,
                                   &driver, *vm, true) < 0) {
-        goto cleanup;
+        return -1;
     }
 
     if (qemuAssignDeviceAliases((*vm)->def, priv->qemuCaps) < 0)
-        goto cleanup;
+        return -1;
 
     (*vm)->def->id = QEMU_HOTPLUG_TEST_DOMAIN_ID;
 
     if (qemuDomainSetPrivatePaths(&driver, *vm) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 static int
index 3d42cabdb877eef96339768d9fa72aff146d409f..347cabe5337be75079c82c71024b38a28fe74b63 100644 (file)
@@ -359,10 +359,8 @@ testUpdateQEMUCaps(const struct testQemuInfo *info,
                    virDomainObjPtr vm,
                    virCapsPtr caps)
 {
-    int ret = -1;
-
     if (!caps)
-        goto cleanup;
+        return -1;
 
     virQEMUCapsSetArch(info->qemuCaps, vm->def->os.arch);
 
@@ -370,17 +368,14 @@ testUpdateQEMUCaps(const struct testQemuInfo *info,
 
     if (testAddCPUModels(info->qemuCaps,
                          !!(info->flags & FLAG_SKIP_LEGACY_CPUS)) < 0)
-        goto cleanup;
+        return -1;
 
     virQEMUCapsInitHostCPUModel(info->qemuCaps, caps->host.arch,
                                 VIR_DOMAIN_VIRT_KVM);
     virQEMUCapsInitHostCPUModel(info->qemuCaps, caps->host.arch,
                                 VIR_DOMAIN_VIRT_QEMU);
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
index 42e62cd874ac53f54606455c1086a96d46a0b2bf..e3bd927dcb544accd8da6496ee0636db1cb0ba6f 100644 (file)
@@ -41,7 +41,6 @@ struct ConfigLookupData {
 
 static int testAuthLookup(const void *args)
 {
-    int ret = -1;
     const struct ConfigLookupData *data = args;
     const char *actual = NULL;
     int rv;
@@ -53,7 +52,7 @@ static int testAuthLookup(const void *args)
                              &actual);
 
     if (rv < 0)
-        goto cleanup;
+        return -1;
 
     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;
         }
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
index 34512d6fd867238226c9fcd2905c959bb0d35cf3..9ec3b576d204cec0f195995ee4253c9515a3ff06 100644 (file)
@@ -104,7 +104,6 @@ static int make_file(const char *path,
 
 static int make_controller_v1(const char *path, mode_t mode)
 {
-    int ret = -1;
     const char *controller;
 
     if (!STRPREFIX(path, fakesysfscgroupdir)) {
@@ -119,12 +118,12 @@ static int make_controller_v1(const char *path, mode_t mode)
         return symlink("cpu,cpuacct", path);
 
     if (real_mkdir(path, mode) < 0)
-        goto cleanup;
+        return -1;
 
 # define MAKE_FILE(name, value) \
     do { \
         if (make_file(path, name, value) < 0) \
-            goto cleanup; \
+            return -1; \
     } while (0)
 
     if (STRPREFIX(controller, "cpu,cpuacct")) {
@@ -225,14 +224,12 @@ static int make_controller_v1(const char *path, mode_t mode)
 
     } else {
         errno = EINVAL;
-        goto cleanup;
+        return -1;
     }
 
 # undef MAKE_FILE
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
index 7e2eff66dcd59e011baf0e0b95785e882d1838d0..38adef93535aabe7986218ba70c76182033bdbc4 100644 (file)
@@ -30,38 +30,35 @@ test1(const void *data G_GNUC_UNUSED)
      * unaligned access.  */
     char array[] = { 1, 2, 3, 4, 5, 6, 7, 8,
                      0x89, 0x8a, 0x8b, 0x8c, 0x8d };
-    int ret = -1;
 
     if (virReadBufInt64BE(array) != 0x0102030405060708ULL)
-        goto cleanup;
+        return -1;
     if (virReadBufInt64BE(array + 5) != 0x060708898a8b8c8dULL)
-        goto cleanup;
+        return -1;
     if (virReadBufInt64LE(array) != 0x0807060504030201ULL)
-        goto cleanup;
+        return -1;
     if (virReadBufInt64LE(array + 5) != 0x8d8c8b8a89080706ULL)
-        goto cleanup;
+        return -1;
 
     if (virReadBufInt32BE(array) != 0x01020304U)
-        goto cleanup;
+        return -1;
     if (virReadBufInt32BE(array + 9) != 0x8a8b8c8dU)
-        goto cleanup;
+        return -1;
     if (virReadBufInt32LE(array) != 0x04030201U)
-        goto cleanup;
+        return -1;
     if (virReadBufInt32LE(array + 9) != 0x8d8c8b8aU)
-        goto cleanup;
+        return -1;
 
     if (virReadBufInt16BE(array) != 0x0102U)
-        goto cleanup;
+        return -1;
     if (virReadBufInt16BE(array + 11) != 0x8c8dU)
-        goto cleanup;
+        return -1;
     if (virReadBufInt16LE(array) != 0x0201U)
-        goto cleanup;
+        return -1;
     if (virReadBufInt16LE(array + 11) != 0x8d8cU)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 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[] = { 1, 2, 3, 4, 5, 6, 7, 8,
                               0x89, 0x8a, 0x8b, 0x8c, 0x8d };
-    int ret = -1;
 
     if (virReadBufInt64BE(array) != 0x0102030405060708ULL)
-        goto cleanup;
+        return -1;
     if (virReadBufInt64BE(array + 5) != 0x060708898a8b8c8dULL)
-        goto cleanup;
+        return -1;
     if (virReadBufInt64LE(array) != 0x0807060504030201ULL)
-        goto cleanup;
+        return -1;
     if (virReadBufInt64LE(array + 5) != 0x8d8c8b8a89080706ULL)
-        goto cleanup;
+        return -1;
 
     if (virReadBufInt32BE(array) != 0x01020304U)
-        goto cleanup;
+        return -1;
     if (virReadBufInt32BE(array + 9) != 0x8a8b8c8dU)
-        goto cleanup;
+        return -1;
     if (virReadBufInt32LE(array) != 0x04030201U)
-        goto cleanup;
+        return -1;
     if (virReadBufInt32LE(array + 9) != 0x8d8c8b8aU)
-        goto cleanup;
+        return -1;
 
     if (virReadBufInt16BE(array) != 0x0102U)
-        goto cleanup;
+        return -1;
     if (virReadBufInt16BE(array + 11) != 0x8c8dU)
-        goto cleanup;
+        return -1;
     if (virReadBufInt16LE(array) != 0x0201U)
-        goto cleanup;
+        return -1;
     if (virReadBufInt16LE(array + 11) != 0x8d8cU)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 static int
index c2e756cdd09c217d672be5ef3069fbda72f3f30e..298409e91991b41144cee2b98698dc604cec7c57 100644 (file)
@@ -35,7 +35,6 @@ VIR_LOG_INIT("tests.keycodetest");
 
 static int testKeycodeMapping(const void *data G_GNUC_UNUSED)
 {
-    int ret = -1;
     int got;
 
 #define TRANSLATE(from, to, val, want) \
@@ -45,7 +44,7 @@ static int testKeycodeMapping(const void *data G_GNUC_UNUSED)
                                             val)) != 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)
 
@@ -60,15 +59,12 @@ static int testKeycodeMapping(const void *data G_GNUC_UNUSED)
 
 #undef TRANSLATE
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
 static int testKeycodeStrings(const void *data G_GNUC_UNUSED)
 {
-    int ret = -1;
     int got;
 
 #define TRANSLATE(from, str, want) \
@@ -77,7 +73,7 @@ static int testKeycodeStrings(const void *data G_GNUC_UNUSED)
                                              str)) != want) { \
             fprintf(stderr, "Converting %s from %s, got %d want %d\n", \
                     str, #from, got, want); \
-            goto cleanup; \
+            return -1; \
         } \
     } while (0)
 
@@ -90,9 +86,7 @@ static int testKeycodeStrings(const void *data G_GNUC_UNUSED)
 
 #undef TRANSLATE
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 static int
index 69d75dfa347d96b5e10dfed41eab04aebed3fe1a..15ad23932ec0312f6816ab4d18d0f07157efc0b4 100644 (file)
@@ -164,8 +164,7 @@ mymain(void)
 #define DO_TEST_FLUSH_PROLOGUE \
     do { \
         if (!(mgr = virMacMapNew(NULL))) { \
-            ret = -1; \
-            goto cleanup; \
+            return EXIT_FAILURE; \
         } \
     } while (0)
 
@@ -222,7 +221,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 == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
index 5d266a28ee5efcc128588350804595476cba8f32..aadbeb1ef455f41a54f85b8c588f1b0ad73fd4d6 100644 (file)
@@ -35,31 +35,28 @@ struct testVirNetDevGetLinkInfoData {
 static int
 testVirNetDevGetLinkInfo(const void *opaque)
 {
-    int ret = -1;
     const struct testVirNetDevGetLinkInfoData *data = opaque;
     virNetDevIfLink lnk;
 
     if (virNetDevGetLinkInfo(data->ifname, &lnk) < 0)
-        goto cleanup;
+        return -1;
 
     if (lnk.state != 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;
     }
 
     if (lnk.speed != data->speed) {
         fprintf(stderr,
                 "Fetched link speed (%u) doesn't match the expected one (%u)",
                 lnk.speed, data->speed);
-        goto cleanup;
+        return -1;
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 static int
index 341afb385b8839e5fd852a68529e95b954b44c38..cd6ae1cff688198ab83c6aa36d29cc2f85ad7425 100644 (file)
@@ -298,7 +298,6 @@ find_fd(int fd, size_t *indx)
 static int
 add_fd(int fd, const char *path)
 {
-    int ret = -1;
     size_t i;
 
     if (find_fd(fd, &i)) {
@@ -309,38 +308,34 @@ add_fd(int fd, const char *path)
 
     if (VIR_REALLOC_N_QUIET(callbacks, nCallbacks + 1) < 0) {
         errno = ENOMEM;
-        goto cleanup;
+        return -1;
     }
 
     callbacks[nCallbacks].path = g_strdup(path);
     callbacks[nCallbacks++].fd = fd;
-    ret = 0;
- cleanup:
-    return ret;
+
+    return 0;
 }
 
 static int
 remove_fd(int fd)
 {
-    int ret = -1;
     size_t i;
 
     if (find_fd(fd, &i)) {
         struct fdCallback cb = callbacks[i];
 
         if (pci_driver_handle_change(cb.fd, cb.path) < 0)
-            goto cleanup;
+            return -1;
 
         VIR_FREE(cb.path);
         if (VIR_DELETE_ELEMENT(callbacks, i, nCallbacks) < 0) {
             errno = EINVAL;
-            goto cleanup;
+            return -1;
         }
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 
@@ -907,36 +902,30 @@ pci_driver_handle_change(int fd G_GNUC_UNUSED, const char *path)
 static int
 pci_driver_handle_bind(const char *path)
 {
-    int ret = -1;
     struct pciDevice *dev = pci_device_find_by_content(path);
     struct pciDriver *driver = pci_driver_find_by_path(path);
 
     if (!driver || !dev) {
         /* No driver, no device or failing driver requested */
         errno = ENODEV;
-        goto cleanup;
+        return -1;
     }
 
-    ret = pci_driver_bind(driver, dev);
- cleanup:
-    return ret;
+    return pci_driver_bind(driver, dev);
 }
 
 static int
 pci_driver_handle_unbind(const char *path)
 {
-    int ret = -1;
     struct pciDevice *dev = pci_device_find_by_content(path);
 
     if (!dev || !dev->driver) {
         /* No device, device not binded or failing driver requested */
         errno = ENODEV;
-        goto cleanup;
+        return -1;
     }
 
-    ret = pci_driver_unbind(dev->driver, dev);
- cleanup:
-    return ret;
+    return pci_driver_unbind(dev->driver, dev);
 }
 
 
index 21dd5382321189c490c912b7b7ca037cab4a9653..68fe9c8345476ebebd5bac48a88797bde81d35e3 100644 (file)
@@ -224,13 +224,12 @@ testVirPCIDeviceIsAssignable(const void *opaque)
     virPCIDevicePtr dev;
 
     if (!(dev = virPCIDeviceNew(data->domain, data->bus, data->slot, data->function)))
-        goto cleanup;
+        return -1;
 
     if (virPCIDeviceIsAssignable(dev, true))
         ret = 0;
 
     virPCIDeviceFree(dev);
- cleanup:
     return ret;
 }
 
index 97fa877445cce094651a33521a6958a667b61281..fe7a3b5b9196cf0f95976e1fa7aa3c4b86fc0256 100644 (file)
@@ -145,26 +145,20 @@ VIR_MOCK_WRAP_RET_ARGS(dbus_connection_send_with_reply_and_block,
 
 static int testPolkitAuthSuccess(const void *opaque G_GNUC_UNUSED)
 {
-    int ret = -1;
-
     if (virPolkitCheckAuth("org.libvirt.test.success",
                            THE_PID,
                            THE_TIME,
                            THE_UID,
                            NULL,
                            true) < 0)
-        goto cleanup;
-
-    ret = 0;
+        return -1;
 
- cleanup:
-    return ret;
+    return 0;
 }
 
 
 static int testPolkitAuthDenied(const void *opaque G_GNUC_UNUSED)
 {
-    int ret = -1;
     int rv;
     virErrorPtr err;
 
@@ -177,28 +171,24 @@ static int testPolkitAuthDenied(const void *opaque G_GNUC_UNUSED)
 
     if (rv == 0) {
         fprintf(stderr, "Unexpected auth success\n");
-        goto cleanup;
+        return -1;
     } else if (rv != -2) {
-        goto cleanup;
+        return -1;
     }
 
     err = virGetLastError();
     if (!err || !strstr(err->message,
                         _("access denied by policy"))) {
         fprintf(stderr, "Incorrect error response\n");
-        goto cleanup;
+        return -1;
     }
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
 static int testPolkitAuthChallenge(const void *opaque G_GNUC_UNUSED)
 {
-    int ret = -1;
     int rv;
     virErrorPtr err;
 
@@ -211,9 +201,9 @@ static int testPolkitAuthChallenge(const void *opaque G_GNUC_UNUSED)
 
     if (rv == 0) {
         fprintf(stderr, "Unexpected auth success\n");
-        goto cleanup;
+        return -1;
     } else if (rv != -2) {
-        goto cleanup;
+        return -1;
     }
 
     err = virGetLastError();
@@ -221,19 +211,15 @@ static int testPolkitAuthChallenge(const void *opaque G_GNUC_UNUSED)
         err->code != VIR_ERR_AUTH_UNAVAILABLE ||
         !strstr(err->message, _("no polkit agent available to authenticate"))) {
         fprintf(stderr, "Incorrect error response\n");
-        goto cleanup;
+        return -1;
     }
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
 static int testPolkitAuthCancelled(const void *opaque G_GNUC_UNUSED)
 {
-    int ret = -1;
     int rv;
     virErrorPtr err;
 
@@ -246,28 +232,24 @@ static int testPolkitAuthCancelled(const void *opaque G_GNUC_UNUSED)
 
     if (rv == 0) {
         fprintf(stderr, "Unexpected auth success\n");
-        goto cleanup;
+        return -1;
     } else if (rv != -2) {
-        goto cleanup;
+        return -1;
     }
 
     err = virGetLastError();
     if (!err || !strstr(err->message,
                        _("user cancelled authentication process"))) {
         fprintf(stderr, "Incorrect error response\n");
-        goto cleanup;
+        return -1;
     }
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
 static int testPolkitAuthDetailsSuccess(const void *opaque G_GNUC_UNUSED)
 {
-    int ret = -1;
     const char *details[] = {
         "org.libvirt.test.person", "Fred",
         NULL,
@@ -279,18 +261,14 @@ static int testPolkitAuthDetailsSuccess(const void *opaque G_GNUC_UNUSED)
                            THE_UID,
                            details,
                            true) < 0)
-        goto cleanup;
-
-    ret = 0;
+        return -1;
 
- cleanup:
-    return ret;
+    return 0;
 }
 
 
 static int testPolkitAuthDetailsDenied(const void *opaque G_GNUC_UNUSED)
 {
-    int ret = -1;
     int rv;
     virErrorPtr err;
     const char *details[] = {
@@ -307,22 +285,19 @@ static int testPolkitAuthDetailsDenied(const void *opaque G_GNUC_UNUSED)
 
     if (rv == 0) {
         fprintf(stderr, "Unexpected auth success\n");
-        goto cleanup;
+        return -1;
     } else if (rv != -2) {
-        goto cleanup;
+        return -1;
     }
 
     err = virGetLastError();
     if (!err || !strstr(err->message,
                         _("access denied by policy"))) {
         fprintf(stderr, "Incorrect error response\n");
-        goto cleanup;
+        return -1;
     }
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 
index 1e408f27579bcecd76980c989f139e122bd49805..fc5f9bf93792838ba3ec94fc8610a4584b814c5b 100644 (file)
@@ -39,7 +39,6 @@ struct testStreqData {
 static int testStreq(const void *args)
 {
     const struct testStreqData *data = args;
-    int ret = -1;
     bool equal = 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;
     }
 
     if (strneq_rv == equal) {
         virFilePrintf(stderr,
                       "STRNEQ not working correctly. Expected %d got %d",
                       (int) equal, (int) strneq_rv);
-        goto cleanup;
+        return -1;
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }
 
 struct testSplitData {
@@ -381,7 +378,6 @@ testStringSortCompare(const void *opaque G_GNUC_UNUSED)
     const char *sortrlist[] = {
         "turducken", "tasty", "goat", "chicken", "astro",
     };
-    int ret = -1;
     size_t i;
 
     qsort(randlist, G_N_ELEMENTS(randlist), sizeof(randlist[0]),
@@ -393,18 +389,16 @@ testStringSortCompare(const void *opaque G_GNUC_UNUSED)
         if (STRNEQ(randlist[i], sortlist[i])) {
             fprintf(stderr, "sortlist[%zu] '%s' != 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' != randrlist[%zu] '%s'\n",
                     i, sortrlist[i], i, randrlist[i]);
-            goto cleanup;
+            return -1;
         }
     }
 
-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }