This loop had automatic variable definitions mixed with code. This patch moves the definitions to the top of the function and puts cleanup for them at the bottom. No functional change. --- src/network/bridge_driver.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index e08a316..68c35e9 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -926,6 +926,7 @@ networkDnsmasqConfContents(virNetworkObjPtr network, virNetworkDNSDefPtr dns = &network->def->dns; virNetworkIpDefPtr tmpipdef, ipdef, ipv4def, ipv6def; bool ipv6SLAAC; + char *saddr = NULL, *eaddr = NULL; *configstr = NULL; @@ -1180,14 +1181,10 @@ networkDnsmasqConfContents(virNetworkObjPtr network, while (ipdef) { for (r = 0; r < ipdef->nranges; r++) { - char *saddr = virSocketAddrFormat(&ipdef->ranges[r].start); - if (!saddr) + if (!(saddr = virSocketAddrFormat(&ipdef->ranges[r].start)) || + !(eaddr = virSocketAddrFormat(&ipdef->ranges[r].end))) goto cleanup; - char *eaddr = virSocketAddrFormat(&ipdef->ranges[r].end); - if (!eaddr) { - VIR_FREE(saddr); - goto cleanup; - } + virBufferAsprintf(&configbuf, "dhcp-range=%s,%s\n", saddr, eaddr); VIR_FREE(saddr); @@ -1289,6 +1286,8 @@ networkDnsmasqConfContents(virNetworkObjPtr network, ret = 0; cleanup: + VIR_FREE(saddr); + VIR_FREE(eaddr); virBufferFreeAndReset(&configbuf); return ret; } -- 2.1.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list