From 0729b3fb1666bf838b9135139143c804f085e740 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Fri, 10 Dec 2021 17:39:57 +0100 Subject: [PATCH] bhyve: refactor virBhyveProbeGrubCaps 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 cleanup label. Signed-off-by: Ján Tomko Reviewed-by: Michal Privoznik --- src/bhyve/bhyve_capabilities.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c index 5a0c6c2b77..ed0df35518 100644 --- a/src/bhyve/bhyve_capabilities.c +++ b/src/bhyve/bhyve_capabilities.c @@ -168,35 +168,27 @@ virBhyveDomainCapsBuild(struct _bhyveConn *conn, int virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps) { - char *binary, *help; - virCommand *cmd; - int ret, exit; + g_autofree char *binary = NULL; + g_autofree char *help = NULL; + g_autoptr(virCommand) cmd = NULL; + int exit; - ret = 0; *caps = 0; - cmd = NULL; - help = NULL; binary = virFindFileInPath("grub-bhyve"); - if (binary == NULL) - goto out; + if (!binary) + return 0; cmd = virCommandNew(binary); virCommandAddArg(cmd, "--help"); virCommandSetOutputBuffer(cmd, &help); - if (virCommandRun(cmd, &exit) < 0) { - ret = -1; - goto out; - } + if (virCommandRun(cmd, &exit) < 0) + return -1; if (strstr(help, "--cons-dev") != NULL) *caps |= BHYVE_GRUB_CAP_CONSDEV; - out: - VIR_FREE(help); - virCommandFree(cmd); - VIR_FREE(binary); - return ret; + return 0; } static int