Adapt to VIR_ALLOC and virAsprintf in src/vmware/*

This commit is contained in:
Michal Privoznik 2013-07-04 12:17:55 +02:00
parent b2c1730e99
commit b24656bcc5
2 changed files with 8 additions and 29 deletions

View File

@ -77,10 +77,8 @@ vmwareCapsInit(void)
NULL, NULL, 0, NULL) == NULL) NULL, NULL, 0, NULL) == NULL)
goto error; goto error;
if (VIR_ALLOC(cpu) < 0) { if (VIR_ALLOC(cpu) < 0)
virReportOOMError();
goto error; goto error;
}
if (!(cpu->arch = caps->host.arch)) { if (!(cpu->arch = caps->host.arch)) {
virReportOOMError(); virReportOOMError();
@ -315,18 +313,9 @@ error:
int int
vmwareConstructVmxPath(char *directoryName, char *name, char **vmxPath) vmwareConstructVmxPath(char *directoryName, char *name, char **vmxPath)
{ {
if (directoryName != NULL) { if (directoryName != NULL)
if (virAsprintf(vmxPath, "%s/%s.vmx", directoryName, name) < 0) { return virAsprintf(vmxPath, "%s/%s.vmx", directoryName, name);
virReportOOMError(); return virAsprintf(vmxPath, "%s.vmx", name);
return -1;
}
} else {
if (virAsprintf(vmxPath, "%s.vmx", name) < 0) {
virReportOOMError();
return -1;
}
}
return 0;
} }
int int
@ -385,10 +374,8 @@ vmwareVmxPath(virDomainDefPtr vmdef, char **vmxPath)
goto cleanup; goto cleanup;
} }
if (vmwareConstructVmxPath(directoryName, vmdef->name, vmxPath) < 0) { if (vmwareConstructVmxPath(directoryName, vmdef->name, vmxPath) < 0)
virReportOOMError();
goto cleanup; goto cleanup;
}
ret = 0; ret = 0;
@ -427,11 +414,7 @@ vmwareMoveFile(char *srcFile, char *dstFile)
int int
vmwareMakePath(char *srcDir, char *srcName, char *srcExt, char **outpath) vmwareMakePath(char *srcDir, char *srcName, char *srcExt, char **outpath)
{ {
if (virAsprintf(outpath, "%s/%s.%s", srcDir, srcName, srcExt) < 0) { return virAsprintf(outpath, "%s/%s.%s", srcDir, srcName, srcExt);
virReportOOMError();
return -1;
}
return 0;
} }
int int
@ -448,10 +431,8 @@ vmwareExtractPid(const char * vmxPath)
goto cleanup; goto cleanup;
if (virAsprintf(&logFilePath, "%s/vmware.log", if (virAsprintf(&logFilePath, "%s/vmware.log",
vmxDir) < 0) { vmxDir) < 0)
virReportOOMError();
goto cleanup; goto cleanup;
}
if ((logFile = fopen(logFilePath, "r")) == NULL) if ((logFile = fopen(logFilePath, "r")) == NULL)
goto cleanup; goto cleanup;

View File

@ -126,10 +126,8 @@ vmwareConnectOpen(virConnectPtr conn,
VIR_FREE(vmrun); VIR_FREE(vmrun);
} }
if (VIR_ALLOC(driver) < 0) { if (VIR_ALLOC(driver) < 0)
virReportOOMError();
return VIR_DRV_OPEN_ERROR; return VIR_DRV_OPEN_ERROR;
}
if (virMutexInit(&driver->lock) < 0) if (virMutexInit(&driver->lock) < 0)
goto cleanup; goto cleanup;