On Mon, Apr 27, 2015 at 02:41:44PM +0800, Zhang Bo wrote: > use cleanup instead of error, so that the allocated strings could also get > freed > when there's no error. > > Signed-off-by: Zhang Bo <[email protected]> > --- > src/conf/domain_conf.c | 16 +++++++++------- > 1 file changed, 9 insertions(+), 7 deletions(-) > > diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c > index 41963cc..8350fe7 100644 > --- a/src/conf/domain_conf.c > +++ b/src/conf/domain_conf.c > @@ -5129,6 +5129,7 @@ virDomainNetIpParseXML(xmlNodePtr node) > char *familyStr = NULL; > int family = AF_UNSPEC; > char *address = NULL; > + int ret = -1;
The 'ret' variable should contain the return value of the function.
I am squashing this in:
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b2640b0..1b520b9 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5124,13 +5124,12 @@ static virDomainNetIpDefPtr
virDomainNetIpParseXML(xmlNodePtr node)
{
/* Parse the prefix in every case */
- virDomainNetIpDefPtr ip = NULL;
+ virDomainNetIpDefPtr ip = NULL, ret = NULL;
char *prefixStr = NULL;
unsigned int prefixValue = 0;
char *familyStr = NULL;
int family = AF_UNSPEC;
char *address = NULL;
- int ret = -1;
if (!(prefixStr = virXMLPropString(node, "prefix")) ||
(virStrToLong_ui(prefixStr, NULL, 10, &prefixValue) < 0)) {
@@ -5163,15 +5162,15 @@ virDomainNetIpParseXML(xmlNodePtr node)
}
ip->prefix = prefixValue;
- ret = 0;
+ ret = ip;
+ ip = NULL;
cleanup:
VIR_FREE(prefixStr);
VIR_FREE(familyStr);
VIR_FREE(address);
- if (ret)
- VIR_FREE(ip);
- return ip;
+ VIR_FREE(ip);
+ return ret;
}
Jan
signature.asc
Description: Digital signature
-- libvir-list mailing list [email protected] https://www.redhat.com/mailman/listinfo/libvir-list
