]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
bhyve: refactor bhyveProbeCapsDeviceHelper
authorJán Tomko <jtomko@redhat.com>
Fri, 10 Dec 2021 16:41:56 +0000 (17:41 +0100)
committerJán Tomko <jtomko@redhat.com>
Mon, 13 Dec 2021 17:20:45 +0000 (18:20 +0100)
Use g_auto and remove the 'ret' variable, as well as the cleanup label.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/bhyve/bhyve_capabilities.c

index ed0df35518adedb84dbc7fcd6d1b56f212aa0639..421d0622cd74da2bbdff2f92c18ff5da3fc2e856 100644 (file)
@@ -199,24 +199,20 @@ bhyveProbeCapsDeviceHelper(unsigned int *caps,
                            const char *errormsg,
                            unsigned int flag)
 {
-    char *error;
-    virCommand *cmd = NULL;
-    int ret = -1, exit;
+    g_autofree char *error = NULL;
+    g_autoptr(virCommand) cmd = NULL;
+    int exit;
 
     cmd = virCommandNew(binary);
     virCommandAddArgList(cmd, bus, device, NULL);
     virCommandSetErrorBuffer(cmd, &error);
     if (virCommandRun(cmd, &exit) < 0)
-        goto cleanup;
+        return -1;
 
     if (strstr(error, errormsg) == NULL)
         *caps |= flag;
 
-    ret = 0;
- cleanup:
-    VIR_FREE(error);
-    virCommandFree(cmd);
-    return ret;
+    return 0;
 }
 
 static int