1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

conf: Use VIR_AUTOPTR(virBitmap) in domain_conf

Let's make use of the auto __cleanup capabilities for virBitmapPtr.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
John Ferlan 2019-02-20 11:04:47 -05:00
parent 6c2e8566f8
commit e2087c2955

View File

@ -1809,8 +1809,8 @@ virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
virBitmapPtr autoCpuset) virBitmapPtr autoCpuset)
{ {
int maxvcpus = virDomainDefGetVcpusMax(def); int maxvcpus = virDomainDefGetVcpusMax(def);
virBitmapPtr allcpumap = NULL;
size_t i; size_t i;
VIR_AUTOPTR(virBitmap) allcpumap = NULL;
if (hostcpus < 0) if (hostcpus < 0)
return -1; return -1;
@ -1837,7 +1837,6 @@ virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
virBitmapToDataBuf(bitmap, VIR_GET_CPUMAP(cpumaps, maplen, i), maplen); virBitmapToDataBuf(bitmap, VIR_GET_CPUMAP(cpumaps, maplen, i), maplen);
} }
virBitmapFree(allcpumap);
return i; return i;
} }
@ -2987,7 +2986,7 @@ virDomainIOThreadIDDefArrayInit(virDomainDefPtr def,
size_t i; size_t i;
ssize_t nxt = -1; ssize_t nxt = -1;
virDomainIOThreadIDDefPtr iothrid = NULL; 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 /* Same value (either 0 or some number), then we have none to fill in or
* the iothreadid array was filled from the XML * the iothreadid array was filled from the XML
@ -3028,7 +3027,6 @@ virDomainIOThreadIDDefArrayInit(virDomainDefPtr def,
retval = 0; retval = 0;
error: error:
virBitmapFree(thrmap);
return retval; return retval;
} }
@ -18326,9 +18324,9 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node,
{ {
int ret = -1; int ret = -1;
virDomainIOThreadIDDefPtr iothrid; virDomainIOThreadIDDefPtr iothrid;
virBitmapPtr cpumask = NULL;
unsigned int iothreadid; unsigned int iothreadid;
char *tmp = NULL; char *tmp = NULL;
VIR_AUTOPTR(virBitmap) cpumask = NULL;
if (!(tmp = virXMLPropString(node, "iothread"))) { if (!(tmp = virXMLPropString(node, "iothread"))) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
@ -18384,7 +18382,6 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node,
cleanup: cleanup:
VIR_FREE(tmp); VIR_FREE(tmp);
virBitmapFree(cpumask);
return ret; return ret;
} }
@ -18396,9 +18393,9 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node,
static virBitmapPtr static virBitmapPtr
virDomainEmulatorPinDefParseXML(xmlNodePtr node) virDomainEmulatorPinDefParseXML(xmlNodePtr node)
{ {
virBitmapPtr def = NULL;
virBitmapPtr ret = NULL; virBitmapPtr ret = NULL;
char *tmp = NULL; char *tmp = NULL;
VIR_AUTOPTR(virBitmap) def = NULL;
if (!(tmp = virXMLPropString(node, "cpuset"))) { if (!(tmp = virXMLPropString(node, "cpuset"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@ -18418,7 +18415,6 @@ virDomainEmulatorPinDefParseXML(xmlNodePtr node)
VIR_STEAL_PTR(ret, def); VIR_STEAL_PTR(ret, def);
cleanup: cleanup:
virBitmapFree(def);
VIR_FREE(tmp); VIR_FREE(tmp);
return ret; return ret;
} }
@ -18779,11 +18775,11 @@ virDomainThreadSchedParseHelper(xmlNodePtr node,
virDomainDefPtr def) virDomainDefPtr def)
{ {
ssize_t next = -1; ssize_t next = -1;
virBitmapPtr map = NULL;
virDomainThreadSchedParamPtr sched; virDomainThreadSchedParamPtr sched;
virProcessSchedPolicy policy; virProcessSchedPolicy policy;
int priority; int priority;
int ret = -1; int ret = -1;
VIR_AUTOPTR(virBitmap) map = NULL;
if (!(map = virDomainSchedulerParse(node, name, &policy, &priority))) if (!(map = virDomainSchedulerParse(node, name, &policy, &priority)))
goto cleanup; goto cleanup;
@ -18806,7 +18802,6 @@ virDomainThreadSchedParseHelper(xmlNodePtr node,
ret = 0; ret = 0;
cleanup: cleanup:
virBitmapFree(map);
return ret; return ret;
} }
@ -19510,12 +19505,12 @@ virDomainCachetuneDefParse(virDomainDefPtr def,
{ {
xmlNodePtr oldnode = ctxt->node; xmlNodePtr oldnode = ctxt->node;
xmlNodePtr *nodes = NULL; xmlNodePtr *nodes = NULL;
virBitmapPtr vcpus = NULL;
virResctrlAllocPtr alloc = NULL; virResctrlAllocPtr alloc = NULL;
virDomainResctrlDefPtr resctrl = NULL; virDomainResctrlDefPtr resctrl = NULL;
ssize_t i = 0; ssize_t i = 0;
int n; int n;
int ret = -1; int ret = -1;
VIR_AUTOPTR(virBitmap) vcpus = NULL;
ctxt->node = node; ctxt->node = node;
@ -19575,7 +19570,6 @@ virDomainCachetuneDefParse(virDomainDefPtr def,
ctxt->node = oldnode; ctxt->node = oldnode;
virDomainResctrlDefFree(resctrl); virDomainResctrlDefFree(resctrl);
virObjectUnref(alloc); virObjectUnref(alloc);
virBitmapFree(vcpus);
VIR_FREE(nodes); VIR_FREE(nodes);
return ret; return ret;
} }
@ -19729,9 +19723,9 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,
{ {
xmlNodePtr oldnode = ctxt->node; xmlNodePtr oldnode = ctxt->node;
xmlNodePtr *nodes = NULL; xmlNodePtr *nodes = NULL;
virBitmapPtr vcpus = NULL;
virResctrlAllocPtr alloc = NULL; virResctrlAllocPtr alloc = NULL;
virDomainResctrlDefPtr resctrl = NULL; virDomainResctrlDefPtr resctrl = NULL;
VIR_AUTOPTR(virBitmap) vcpus = NULL;
ssize_t i = 0; ssize_t i = 0;
int n; int n;
@ -19790,7 +19784,6 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,
ctxt->node = oldnode; ctxt->node = oldnode;
virDomainResctrlDefFree(resctrl); virDomainResctrlDefFree(resctrl);
virObjectUnref(alloc); virObjectUnref(alloc);
virBitmapFree(vcpus);
VIR_FREE(nodes); VIR_FREE(nodes);
return ret; return ret;
} }