On Wed, Feb 20, 2019 at 09:46:59AM -0500, John Ferlan wrote:
Let's make use of the auto __cleanup capabilities cleaning up any
now unnecessary goto paths.
At this scale, separating the AUTOFREE conversion and the return values
would really make this easier to read.
Also, this fails compilation with clang.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/conf/domain_conf.c | 1890 ++++++++++++++--------------------------
1 file changed, 660 insertions(+), 1230 deletions(-)
@@ -7138,11 +7092,11 @@
virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED,
xmlNodePtr alias = NULL;
xmlNodePtr boot = NULL;
xmlNodePtr rom = NULL;
- char *type = NULL;
- char *romenabled = NULL;
- char *rombar = NULL;
- char *aliasStr = NULL;
int ret = -1;
+ VIR_AUTOFREE(char *) type = NULL;
conf/domain_conf.c:7096:26: error: unused variable 'type'
[-Werror,-Wunused-variable]
VIR_AUTOFREE(char *) type = NULL;
^
+ VIR_AUTOFREE(char *) romenabled = NULL;
+ VIR_AUTOFREE(char *) rombar = NULL;
+ VIR_AUTOFREE(char *) aliasStr = NULL;
virDomainDeviceInfoClear(info);
@@ -13013,15 +12748,15 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlopt,
xmlXPathContextPtr ctxt,
unsigned int flags)
{
- char *type = NULL;
- char *path = NULL;
- char *model = NULL;
- char *backend = NULL;
- char *version = NULL;
virDomainTPMDefPtr def;
xmlNodePtr save = ctxt->node;
- xmlNodePtr *backends = NULL;
int nbackends;
+ VIR_AUTOFREE(char *) type = NULL;
conf/domain_conf.c:12754:26: error: unused variable 'type'
[-Werror,-Wunused-variable]
VIR_AUTOFREE(char *) type = NULL;
^
+ VIR_AUTOFREE(char *) path = NULL;
+ VIR_AUTOFREE(char *) model = NULL;
+ VIR_AUTOFREE(char *) backend = NULL;
+ VIR_AUTOFREE(char *) version = NULL;
+ VIR_AUTOFREE(xmlNodePtr *) backends = NULL;
if (VIR_ALLOC(def) < 0)
return NULL;
@@ -18549,7 +18093,8 @@ virDomainHugepagesParseXML(xmlNodePtr node,
{
int ret = -1;
xmlNodePtr oldnode = ctxt->node;
- char *unit = NULL, *nodeset = NULL;
+ VIR_AUTOFREE(char *) unit = NULL;
conf/domain_conf.c:18096:26: error: unused variable 'unit'
[-Werror,-Wunused-variable]
VIR_AUTOFREE(char *) unit = NULL;
^
+ VIR_AUTOFREE(char *) nodeset = NULL;
ctxt->node = node;
Jano