In networkDnsmasqConfContents() there's a for() loop which
initializes some variables in its initialization block. This
makes both the loop() statement and variable declaration block
look needlessly ugly. Speaking of variable declaration, also move
some variables which are used only within blocks into their
respective blocks.

Signed-off-by: Michal Privoznik <mpriv...@redhat.com>
---
 src/network/bridge_driver.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 7e5fab630b..2d8bebdd2f 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -1057,16 +1057,14 @@ networkDnsmasqConfContents(virNetworkObj *obj,
 {
     virNetworkDef *def = virNetworkObjGetDef(obj);
     g_auto(virBuffer) configbuf = VIR_BUFFER_INITIALIZER;
-    int r;
     int nbleases = 0;
     size_t i;
     virNetworkDNSDef *dns = &def->dns;
     bool wantDNS = dns->enable != VIR_TRISTATE_BOOL_NO;
-    virNetworkIPDef *tmpipdef;
-    virNetworkIPDef *ipdef;
-    virNetworkIPDef *ipv4def;
-    virNetworkIPDef *ipv6def;
-    bool ipv6SLAAC;
+    virNetworkIPDef *ipdef = NULL;
+    virNetworkIPDef *ipv4def = NULL;
+    virNetworkIPDef *ipv6def = NULL;
+    bool ipv6SLAAC = false;
 
     *configstr = NULL;
 
@@ -1186,6 +1184,8 @@ networkDnsmasqConfContents(virNetworkObj *obj,
                           "interface=%s\n",
                           def->bridge);
     } else {
+        virNetworkIPDef *tmpipdef = NULL;
+
         virBufferAddLit(&configbuf, "bind-interfaces\n");
         /*
          * --interface does not actually work with dnsmasq < 2.47,
@@ -1312,9 +1312,7 @@ networkDnsmasqConfContents(virNetworkObj *obj,
     }
 
     /* Find the first dhcp for both IPv4 and IPv6 */
-    for (i = 0, ipv4def = NULL, ipv6def = NULL, ipv6SLAAC = false;
-         (ipdef = virNetworkDefGetIPByIndex(def, AF_UNSPEC, i));
-         i++) {
+    for (i = 0; (ipdef = virNetworkDefGetIPByIndex(def, AF_UNSPEC, i)); i++) {
         if (VIR_SOCKET_ADDR_IS_FAMILY(&ipdef->address, AF_INET)) {
             if (ipdef->nranges || ipdef->nhosts) {
                 if (ipv4def) {
@@ -1370,6 +1368,7 @@ networkDnsmasqConfContents(virNetworkObj *obj,
 
     while (ipdef) {
         int prefix;
+        int r;
 
         prefix = virNetworkIPDefPrefix(ipdef);
         if (prefix < 0) {
-- 
2.32.0

Reply via email to