mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 09:53:10 +00:00
vmware: refactor vmwareExtractVersion
Use g_auto for cleanup and remove 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
4f1c1c9ff7
commit
e86d62f8f7
@ -242,11 +242,10 @@ vmwareParseVersionStr(int type, const char *verbuf, unsigned long *version)
|
|||||||
int
|
int
|
||||||
vmwareExtractVersion(struct vmware_driver *driver)
|
vmwareExtractVersion(struct vmware_driver *driver)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
g_autoptr(virCommand) cmd = NULL;
|
||||||
virCommand *cmd = NULL;
|
g_autofree char *outbuf = NULL;
|
||||||
char * outbuf = NULL;
|
g_autofree char *bin = NULL;
|
||||||
char *bin = NULL;
|
g_autofree char *vmwarePath = NULL;
|
||||||
char *vmwarePath = NULL;
|
|
||||||
|
|
||||||
vmwarePath = g_path_get_dirname(driver->vmrun);
|
vmwarePath = g_path_get_dirname(driver->vmrun);
|
||||||
|
|
||||||
@ -266,7 +265,7 @@ vmwareExtractVersion(struct vmware_driver *driver)
|
|||||||
default:
|
default:
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("invalid driver type for version detection"));
|
_("invalid driver type for version detection"));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd = virCommandNewArgList(bin, "-v", NULL);
|
cmd = virCommandNewArgList(bin, "-v", NULL);
|
||||||
@ -274,19 +273,12 @@ vmwareExtractVersion(struct vmware_driver *driver)
|
|||||||
virCommandSetErrorBuffer(cmd, &outbuf);
|
virCommandSetErrorBuffer(cmd, &outbuf);
|
||||||
|
|
||||||
if (virCommandRun(cmd, NULL) < 0)
|
if (virCommandRun(cmd, NULL) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (vmwareParseVersionStr(driver->type, outbuf, &driver->version) < 0)
|
if (vmwareParseVersionStr(driver->type, outbuf, &driver->version) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
virCommandFree(cmd);
|
|
||||||
VIR_FREE(outbuf);
|
|
||||||
VIR_FREE(bin);
|
|
||||||
VIR_FREE(vmwarePath);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
Loading…
Reference in New Issue
Block a user