]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
testVshTableHeader: Cleanup
authorTim Wiederhake <twiederh@redhat.com>
Mon, 8 Nov 2021 11:49:16 +0000 (12:49 +0100)
committerTim Wiederhake <twiederh@redhat.com>
Mon, 8 Nov 2021 13:32:32 +0000 (14:32 +0100)
Remove unnecessary label and goto. This also fixes a bug where a
failure to create the table would result in the test passing.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tests/vshtabletest.c

index 716b11dbc0f277c5a9e50f2b6a290742125feed4..41ceec0a51caf7031732f315929a7c8a935e59bd 100644 (file)
@@ -45,7 +45,8 @@ static int
 testVshTableHeader(const void *opaque G_GNUC_UNUSED)
 {
     int ret = 0;
-    char *act = NULL;
+    g_autofree char *act = NULL;
+    g_autofree char *act2 = NULL;
     const char *exp =
         " 1   fedora28   running\n"
         " 2   rhel7.5    running\n";
@@ -58,7 +59,7 @@ testVshTableHeader(const void *opaque G_GNUC_UNUSED)
     g_autoptr(vshTable) table = vshTableNew("Id", "Name", "State",
                                     NULL); //to ask about return
     if (!table)
-        goto cleanup;
+        return -1;
 
     vshTableRowAppend(table, "1", "fedora28", "running", NULL);
     vshTableRowAppend(table, "2", "rhel7.5", "running",
@@ -68,13 +69,10 @@ testVshTableHeader(const void *opaque G_GNUC_UNUSED)
     if (virTestCompareToString(exp, act) < 0)
         ret = -1;
 
-    VIR_FREE(act);
-    act = vshTablePrintToString(table, true);
-    if (virTestCompareToString(exp2, act) < 0)
+    act2 = vshTablePrintToString(table, true);
+    if (virTestCompareToString(exp2, act2) < 0)
         ret = -1;
 
- cleanup:
-    VIR_FREE(act);
     return ret;
 }