From 681df4776beefe11588afae5effce40757530619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Fri, 10 Dec 2021 17:41:56 +0100 Subject: [PATCH] bhyve: refactor bhyveProbeCapsFromHelp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use g_auto and remove the 'ret' variable, as well as the out label. Signed-off-by: Ján Tomko Reviewed-by: Michal Privoznik --- src/bhyve/bhyve_capabilities.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c index 421d0622cd..b065256cf0 100644 --- a/src/bhyve/bhyve_capabilities.c +++ b/src/bhyve/bhyve_capabilities.c @@ -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