提交 adca6744 编写于 作者: M Michal Privoznik

vmware: Use g_strdup_printf() instead of virAsprintf()

Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NDaniel Henrique Barboza <danielhb413@gmail.com>
上级 24d213b0
......@@ -275,18 +275,15 @@ vmwareExtractVersion(struct vmware_driver *driver)
switch (driver->type) {
case VMWARE_DRIVER_PLAYER:
if (virAsprintf(&bin, "%s/%s", vmwarePath, "vmplayer") < 0)
goto cleanup;
bin = g_strdup_printf("%s/%s", vmwarePath, "vmplayer");
break;
case VMWARE_DRIVER_WORKSTATION:
if (virAsprintf(&bin, "%s/%s", vmwarePath, "vmware") < 0)
goto cleanup;
bin = g_strdup_printf("%s/%s", vmwarePath, "vmware");
break;
case VMWARE_DRIVER_FUSION:
if (virAsprintf(&bin, "%s/%s", vmwarePath, "vmware-vmx") < 0)
goto cleanup;
bin = g_strdup_printf("%s/%s", vmwarePath, "vmware-vmx");
break;
default:
......@@ -365,19 +362,13 @@ vmwareParsePath(const char *path, char **directory, char **filename)
return -1;
}
int
void
vmwareConstructVmxPath(char *directoryName, char *name, char **vmxPath)
{
int ret;
if (directoryName != NULL)
ret = virAsprintf(vmxPath, "%s/%s.vmx", directoryName, name);
*vmxPath = g_strdup_printf("%s/%s.vmx", directoryName, name);
else
ret = virAsprintf(vmxPath, "%s.vmx", name);
if (ret < 0)
return -1;
return 0;
*vmxPath = g_strdup_printf("%s.vmx", name);
}
int
......@@ -437,8 +428,7 @@ vmwareVmxPath(virDomainDefPtr vmdef, char **vmxPath)
goto cleanup;
}
if (vmwareConstructVmxPath(directoryName, vmdef->name, vmxPath) < 0)
goto cleanup;
vmwareConstructVmxPath(directoryName, vmdef->name, vmxPath);
ret = 0;
......@@ -477,8 +467,7 @@ vmwareMoveFile(char *srcFile, char *dstFile)
int
vmwareMakePath(char *srcDir, char *srcName, char *srcExt, char **outpath)
{
if (virAsprintf(outpath, "%s/%s.%s", srcDir, srcName, srcExt) < 0)
return -1;
*outpath = g_strdup_printf("%s/%s.%s", srcDir, srcName, srcExt);
return 0;
}
......@@ -495,9 +484,7 @@ vmwareExtractPid(const char * vmxPath)
if ((vmxDir = mdir_name(vmxPath)) == NULL)
goto cleanup;
if (virAsprintf(&logFilePath, "%s/vmware.log",
vmxDir) < 0)
goto cleanup;
logFilePath = g_strdup_printf("%s/vmware.log", vmxDir);
if ((logFile = fopen(logFilePath, "r")) == NULL)
goto cleanup;
......
......@@ -71,8 +71,8 @@ int vmwareParseVersionStr(int type, const char *buf, unsigned long *version);
int vmwareDomainConfigDisplay(vmwareDomainPtr domain, virDomainDefPtr vmdef);
int vmwareConstructVmxPath(char *directoryName, char *name,
char **vmxPath);
void vmwareConstructVmxPath(char *directoryName, char *name,
char **vmxPath);
int vmwareVmxPath(virDomainDefPtr vmdef, char **vmxPath);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册