]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
bhyve: refactor bhyveProbeCapsFromHelp
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 out label.

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

index 421d0622cd74da2bbdff2f92c18ff5da3fc2e856..b065256cf0f036874afd824a899ff7ed7d07d638 100644 (file)
@@ -218,17 +218,15 @@ bhyveProbeCapsDeviceHelper(unsigned int *caps,
 static int
 bhyveProbeCapsFromHelp(unsigned int *caps, char *binary)
 {
-    char *help;
-    virCommand *cmd = NULL;
-    int ret = 0, exit;
+    g_autofree char *help = NULL;
+    g_autoptr(virCommand) cmd = NULL;
+    int exit;
 
     cmd = virCommandNew(binary);
     virCommandAddArg(cmd, "-h");
     virCommandSetErrorBuffer(cmd, &help);
-    if (virCommandRun(cmd, &exit) < 0) {
-        ret = -1;
-        goto out;
-    }
+    if (virCommandRun(cmd, &exit) < 0)
+        return -1;
 
     if (strstr(help, "-u:") != NULL)
         *caps |= BHYVE_CAP_RTC_UTC;
@@ -239,10 +237,7 @@ bhyveProbeCapsFromHelp(unsigned int *caps, char *binary)
     if (strstr(help, "-c vcpus") == NULL)
         *caps |= BHYVE_CAP_CPUTOPOLOGY;
 
- out:
-    VIR_FREE(help);
-    virCommandFree(cmd);
-    return ret;
+    return 0;
 }
 
 static int