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