From 6ffb4441867214fd44b5b4fb2569bf76fd7b5a49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Thu, 5 Mar 2020 17:17:55 +0100 Subject: [PATCH] vz: use g_autofree in prlsdkConvertCpuInfo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Convert the function to use g_autofree to silence -Wmaybe-uninitialized. Signed-off-by: Ján Tomko Reviewed-by: Peter Krempa --- src/vz/vz_sdk.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index c49204de1d..9cee6f1fde 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -1456,44 +1456,40 @@ prlsdkConvertCpuInfo(PRL_HANDLE sdkdom, virDomainDefPtr def, virDomainXMLOptionPtr xmlopt) { - char *buf; + g_autofree char *buf = NULL; int hostcpus; PRL_UINT32 cpuCount; PRL_RESULT pret; - int ret = -1; if ((hostcpus = virHostCPUGetCount()) < 0) - goto cleanup; + return -1; /* get number of CPUs */ pret = PrlVmCfg_GetCpuCount(sdkdom, &cpuCount); - prlsdkCheckRetGoto(pret, cleanup); + prlsdkCheckRetExit(pret, -1); if (cpuCount > hostcpus) cpuCount = hostcpus; if (virDomainDefSetVcpusMax(def, cpuCount, xmlopt) < 0) - goto cleanup; + return -1; if (virDomainDefSetVcpus(def, cpuCount) < 0) - goto cleanup; + return -1; if (!(buf = prlsdkGetStringParamVar(PrlVmCfg_GetCpuMask, sdkdom))) - goto cleanup; + return -1; if (strlen(buf) == 0) { if (!(def->cpumask = virBitmapNew(hostcpus))) - goto cleanup; + return -1; virBitmapSetAll(def->cpumask); } else { if (virBitmapParse(buf, &def->cpumask, hostcpus) < 0) - goto cleanup; + return -1; } - ret = 0; - cleanup: - VIR_FREE(buf); - return ret; + return 0; } static int