提交 198d503c 编写于 作者: L Laine Stump

network: cleanup range loop in networkDnsmasqConfContents

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.

Part of fix for: https://bugzilla.redhat.com/show_bug.cgi?id=985653
上级 1e334a0a
...@@ -926,6 +926,7 @@ networkDnsmasqConfContents(virNetworkObjPtr network, ...@@ -926,6 +926,7 @@ networkDnsmasqConfContents(virNetworkObjPtr network,
virNetworkDNSDefPtr dns = &network->def->dns; virNetworkDNSDefPtr dns = &network->def->dns;
virNetworkIpDefPtr tmpipdef, ipdef, ipv4def, ipv6def; virNetworkIpDefPtr tmpipdef, ipdef, ipv4def, ipv6def;
bool ipv6SLAAC; bool ipv6SLAAC;
char *saddr = NULL, *eaddr = NULL;
*configstr = NULL; *configstr = NULL;
...@@ -1180,14 +1181,10 @@ networkDnsmasqConfContents(virNetworkObjPtr network, ...@@ -1180,14 +1181,10 @@ networkDnsmasqConfContents(virNetworkObjPtr network,
while (ipdef) { while (ipdef) {
for (r = 0; r < ipdef->nranges; r++) { for (r = 0; r < ipdef->nranges; r++) {
char *saddr = virSocketAddrFormat(&ipdef->ranges[r].start); if (!(saddr = virSocketAddrFormat(&ipdef->ranges[r].start)) ||
if (!saddr) !(eaddr = virSocketAddrFormat(&ipdef->ranges[r].end)))
goto cleanup; goto cleanup;
char *eaddr = virSocketAddrFormat(&ipdef->ranges[r].end);
if (!eaddr) {
VIR_FREE(saddr);
goto cleanup;
}
virBufferAsprintf(&configbuf, "dhcp-range=%s,%s\n", virBufferAsprintf(&configbuf, "dhcp-range=%s,%s\n",
saddr, eaddr); saddr, eaddr);
VIR_FREE(saddr); VIR_FREE(saddr);
...@@ -1289,6 +1286,8 @@ networkDnsmasqConfContents(virNetworkObjPtr network, ...@@ -1289,6 +1286,8 @@ networkDnsmasqConfContents(virNetworkObjPtr network,
ret = 0; ret = 0;
cleanup: cleanup:
VIR_FREE(saddr);
VIR_FREE(eaddr);
virBufferFreeAndReset(&configbuf); virBufferFreeAndReset(&configbuf);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册