int
vmwareExtractVersion(struct vmware_driver *driver)
{
- int ret = -1;
- virCommand *cmd = NULL;
- char * outbuf = NULL;
- char *bin = NULL;
- char *vmwarePath = NULL;
+ g_autoptr(virCommand) cmd = NULL;
+ g_autofree char *outbuf = NULL;
+ g_autofree char *bin = NULL;
+ g_autofree char *vmwarePath = NULL;
vmwarePath = g_path_get_dirname(driver->vmrun);
default:
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("invalid driver type for version detection"));
- goto cleanup;
+ return -1;
}
cmd = virCommandNewArgList(bin, "-v", NULL);
virCommandSetErrorBuffer(cmd, &outbuf);
if (virCommandRun(cmd, NULL) < 0)
- goto cleanup;
+ return -1;
if (vmwareParseVersionStr(driver->type, outbuf, &driver->version) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- virCommandFree(cmd);
- VIR_FREE(outbuf);
- VIR_FREE(bin);
- VIR_FREE(vmwarePath);
- return ret;
+ return 0;
}
int