提交 6ffb4441 编写于 作者: J Ján Tomko

vz: use g_autofree in prlsdkConvertCpuInfo

Convert the function to use g_autofree to silence -Wmaybe-uninitialized.
Signed-off-by: NJán Tomko <jtomko@redhat.com>
Reviewed-by: NPeter Krempa <pkrempa@redhat.com>
上级 e7741937
...@@ -1456,44 +1456,40 @@ prlsdkConvertCpuInfo(PRL_HANDLE sdkdom, ...@@ -1456,44 +1456,40 @@ prlsdkConvertCpuInfo(PRL_HANDLE sdkdom,
virDomainDefPtr def, virDomainDefPtr def,
virDomainXMLOptionPtr xmlopt) virDomainXMLOptionPtr xmlopt)
{ {
char *buf; g_autofree char *buf = NULL;
int hostcpus; int hostcpus;
PRL_UINT32 cpuCount; PRL_UINT32 cpuCount;
PRL_RESULT pret; PRL_RESULT pret;
int ret = -1;
if ((hostcpus = virHostCPUGetCount()) < 0) if ((hostcpus = virHostCPUGetCount()) < 0)
goto cleanup; return -1;
/* get number of CPUs */ /* get number of CPUs */
pret = PrlVmCfg_GetCpuCount(sdkdom, &cpuCount); pret = PrlVmCfg_GetCpuCount(sdkdom, &cpuCount);
prlsdkCheckRetGoto(pret, cleanup); prlsdkCheckRetExit(pret, -1);
if (cpuCount > hostcpus) if (cpuCount > hostcpus)
cpuCount = hostcpus; cpuCount = hostcpus;
if (virDomainDefSetVcpusMax(def, cpuCount, xmlopt) < 0) if (virDomainDefSetVcpusMax(def, cpuCount, xmlopt) < 0)
goto cleanup; return -1;
if (virDomainDefSetVcpus(def, cpuCount) < 0) if (virDomainDefSetVcpus(def, cpuCount) < 0)
goto cleanup; return -1;
if (!(buf = prlsdkGetStringParamVar(PrlVmCfg_GetCpuMask, sdkdom))) if (!(buf = prlsdkGetStringParamVar(PrlVmCfg_GetCpuMask, sdkdom)))
goto cleanup; return -1;
if (strlen(buf) == 0) { if (strlen(buf) == 0) {
if (!(def->cpumask = virBitmapNew(hostcpus))) if (!(def->cpumask = virBitmapNew(hostcpus)))
goto cleanup; return -1;
virBitmapSetAll(def->cpumask); virBitmapSetAll(def->cpumask);
} else { } else {
if (virBitmapParse(buf, &def->cpumask, hostcpus) < 0) if (virBitmapParse(buf, &def->cpumask, hostcpus) < 0)
goto cleanup; return -1;
} }
ret = 0; return 0;
cleanup:
VIR_FREE(buf);
return ret;
} }
static int static int
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册