Let's make use of the auto __cleanup capabilities for virBitmapPtr. Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- src/conf/domain_conf.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 542d53e709..f27af65d80 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1803,8 +1803,8 @@ virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def, virBitmapPtr autoCpuset) { int maxvcpus = virDomainDefGetVcpusMax(def); - virBitmapPtr allcpumap = NULL; size_t i; + VIR_AUTOPTR(virBitmap) allcpumap = NULL; if (hostcpus < 0) return -1; @@ -1831,7 +1831,6 @@ virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def, virBitmapToDataBuf(bitmap, VIR_GET_CPUMAP(cpumaps, maplen, i), maplen); } - virBitmapFree(allcpumap); return i; } @@ -2988,7 +2987,7 @@ virDomainIOThreadIDDefArrayInit(virDomainDefPtr def, size_t i; ssize_t nxt = -1; virDomainIOThreadIDDefPtr iothrid = NULL; - virBitmapPtr thrmap = NULL; + VIR_AUTOPTR(virBitmap) thrmap = NULL; /* Same value (either 0 or some number), then we have none to fill in or * the iothreadid array was filled from the XML @@ -3029,7 +3028,6 @@ virDomainIOThreadIDDefArrayInit(virDomainDefPtr def, retval = 0; error: - virBitmapFree(thrmap); return retval; } @@ -18327,9 +18325,9 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node, { int ret = -1; virDomainIOThreadIDDefPtr iothrid; - virBitmapPtr cpumask = NULL; unsigned int iothreadid; char *tmp = NULL; + VIR_AUTOPTR(virBitmap) cpumask = NULL; if (!(tmp = virXMLPropString(node, "iothread"))) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -18385,7 +18383,6 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node, cleanup: VIR_FREE(tmp); - virBitmapFree(cpumask); return ret; } @@ -18397,9 +18394,9 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node, static virBitmapPtr virDomainEmulatorPinDefParseXML(xmlNodePtr node) { - virBitmapPtr def = NULL; virBitmapPtr ret = NULL; char *tmp = NULL; + VIR_AUTOPTR(virBitmap) def = NULL; if (!(tmp = virXMLPropString(node, "cpuset"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -18419,7 +18416,6 @@ virDomainEmulatorPinDefParseXML(xmlNodePtr node) VIR_STEAL_PTR(ret, def); cleanup: - virBitmapFree(def); VIR_FREE(tmp); return ret; } @@ -18780,11 +18776,11 @@ virDomainThreadSchedParseHelper(xmlNodePtr node, virDomainDefPtr def) { ssize_t next = -1; - virBitmapPtr map = NULL; virDomainThreadSchedParamPtr sched; virProcessSchedPolicy policy; int priority; int ret = -1; + VIR_AUTOPTR(virBitmap) map = NULL; if (!(map = virDomainSchedulerParse(node, name, &policy, &priority))) goto cleanup; @@ -18807,7 +18803,6 @@ virDomainThreadSchedParseHelper(xmlNodePtr node, ret = 0; cleanup: - virBitmapFree(map); return ret; } @@ -19511,12 +19506,12 @@ virDomainCachetuneDefParse(virDomainDefPtr def, { xmlNodePtr oldnode = ctxt->node; xmlNodePtr *nodes = NULL; - virBitmapPtr vcpus = NULL; virResctrlAllocPtr alloc = NULL; virDomainResctrlDefPtr resctrl = NULL; ssize_t i = 0; int n; int ret = -1; + VIR_AUTOPTR(virBitmap) vcpus = NULL; ctxt->node = node; @@ -19576,7 +19571,6 @@ virDomainCachetuneDefParse(virDomainDefPtr def, ctxt->node = oldnode; virDomainResctrlDefFree(resctrl); virObjectUnref(alloc); - virBitmapFree(vcpus); VIR_FREE(nodes); return ret; } @@ -19730,9 +19724,9 @@ virDomainMemorytuneDefParse(virDomainDefPtr def, { xmlNodePtr oldnode = ctxt->node; xmlNodePtr *nodes = NULL; - virBitmapPtr vcpus = NULL; virResctrlAllocPtr alloc = NULL; virDomainResctrlDefPtr resctrl = NULL; + VIR_AUTOPTR(virBitmap) vcpus = NULL; ssize_t i = 0; int n; @@ -19791,7 +19785,6 @@ virDomainMemorytuneDefParse(virDomainDefPtr def, ctxt->node = oldnode; virDomainResctrlDefFree(resctrl); virObjectUnref(alloc); - virBitmapFree(vcpus); VIR_FREE(nodes); return ret; } -- 2.20.1