mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-26 13:22:20 +00:00
bhyve: refactor virBhyveProbeGrubCaps
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:
parent
32256aa87e
commit
0729b3fb16
@ -168,35 +168,27 @@ virBhyveDomainCapsBuild(struct _bhyveConn *conn,
|
|||||||
int
|
int
|
||||||
virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps)
|
virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps)
|
||||||
{
|
{
|
||||||
char *binary, *help;
|
g_autofree char *binary = NULL;
|
||||||
virCommand *cmd;
|
g_autofree char *help = NULL;
|
||||||
int ret, exit;
|
g_autoptr(virCommand) cmd = NULL;
|
||||||
|
int exit;
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
*caps = 0;
|
*caps = 0;
|
||||||
cmd = NULL;
|
|
||||||
help = NULL;
|
|
||||||
|
|
||||||
binary = virFindFileInPath("grub-bhyve");
|
binary = virFindFileInPath("grub-bhyve");
|
||||||
if (binary == NULL)
|
if (!binary)
|
||||||
goto out;
|
return 0;
|
||||||
|
|
||||||
cmd = virCommandNew(binary);
|
cmd = virCommandNew(binary);
|
||||||
virCommandAddArg(cmd, "--help");
|
virCommandAddArg(cmd, "--help");
|
||||||
virCommandSetOutputBuffer(cmd, &help);
|
virCommandSetOutputBuffer(cmd, &help);
|
||||||
if (virCommandRun(cmd, &exit) < 0) {
|
if (virCommandRun(cmd, &exit) < 0)
|
||||||
ret = -1;
|
return -1;
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strstr(help, "--cons-dev") != NULL)
|
if (strstr(help, "--cons-dev") != NULL)
|
||||||
*caps |= BHYVE_GRUB_CAP_CONSDEV;
|
*caps |= BHYVE_GRUB_CAP_CONSDEV;
|
||||||
|
|
||||||
out:
|
return 0;
|
||||||
VIR_FREE(help);
|
|
||||||
virCommandFree(cmd);
|
|
||||||
VIR_FREE(binary);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user