[PATCH 17/34] tests: Refactor control flow in testBackingXMLjsonXML

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Get rid of the 'cleanup' label.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 tests/qemublocktest.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
index b1d1ed943c..96c70e381a 100644
--- a/tests/qemublocktest.c
+++ b/tests/qemublocktest.c
@@ -51,7 +51,6 @@ testBackingXMLjsonXML(const void *args)
     VIR_AUTOFREE(char *) propsstr = NULL;
     VIR_AUTOFREE(char *) protocolwrapper = NULL;
     VIR_AUTOFREE(char *) actualxml = NULL;
-    int ret = -1;
     VIR_AUTOUNREF(virStorageSourcePtr) xmlsrc = NULL;
     VIR_AUTOUNREF(virStorageSourcePtr) jsonsrc = NULL;

@@ -61,36 +60,36 @@ testBackingXMLjsonXML(const void *args)
     xmlsrc->type = data->type;

     if (!(xml = virXMLParseStringCtxt(data->xml, "(test storage source XML)", &ctxt)))
-        goto cleanup;
+        return -1;

     if (virDomainDiskSourceParse(ctxt->node, ctxt, xmlsrc, 0, NULL) < 0) {
         fprintf(stderr, "failed to parse disk source xml\n");
-        goto cleanup;
+        return -1;
     }

     if (!(backendprops = qemuBlockStorageSourceGetBackendProps(xmlsrc, true))) {
         fprintf(stderr, "failed to format disk source json\n");
-        goto cleanup;
+        return -1;
     }

     if (virJSONValueObjectCreate(&wrapper, "a:file", &backendprops, NULL) < 0)
-        goto cleanup;
+        return -1;

     if (!(propsstr = virJSONValueToString(wrapper, false)))
-        goto cleanup;
+        return -1;

     if (virAsprintf(&protocolwrapper, "json:%s", propsstr) < 0)
-        goto cleanup;
+        return -1;

     if (!(jsonsrc = virStorageSourceNewFromBackingAbsolute(protocolwrapper))) {
         fprintf(stderr, "failed to parse disk json\n");
-        goto cleanup;
+        return -1;
     }

     if (virDomainDiskSourceFormat(&buf, jsonsrc, 0, 0, true, false, false, NULL) < 0 ||
         !(actualxml = virBufferContentAndReset(&buf))) {
         fprintf(stderr, "failed to format disk source xml\n");
-        goto cleanup;
+        return -1;
     }

     if (STRNEQ(actualxml, data->xml)) {
@@ -98,13 +97,10 @@ testBackingXMLjsonXML(const void *args)
                         "actual storage source xml:\n%s\n"
                         "intermediate json:\n%s\n",
                         data->xml, actualxml, protocolwrapper);
-        goto cleanup;
+        return -1;
     }

-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }


-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux