1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

bhyve: refactor bhyveProbeCapsDeviceHelper

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>
This commit is contained in:
Ján Tomko 2021-12-10 17:41:56 +01:00
parent 0729b3fb16
commit c5316be7a1

View File

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