From c5316be7a11bbfab2ce75a3edf903091165a493c 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 bhyveProbeCapsDeviceHelper 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 | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c index ed0df35518..421d0622cd 100644 --- a/src/bhyve/bhyve_capabilities.c +++ b/src/bhyve/bhyve_capabilities.c @@ -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