[PATCH 1/2] nwfilter: Clean up virNWFilterDetermineMissingVarsRec returns

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rather than using loop break;'s in order to force a return
of rc = -1, let's just return -1 immediately on the various
error paths and then return 0 on the success path.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/nwfilter/nwfilter_gentech_driver.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter_gentech_driver.c
index 6758200b5..7a3d115ba 100644
--- a/src/nwfilter/nwfilter_gentech_driver.c
+++ b/src/nwfilter/nwfilter_gentech_driver.c
@@ -494,7 +494,7 @@ virNWFilterDetermineMissingVarsRec(virNWFilterDefPtr filter,
                                    virNWFilterDriverStatePtr driver)
 {
     virNWFilterObjPtr obj;
-    int rc = 0;
+    int rc;
     size_t i, j;
     virNWFilterDefPtr next_filter;
     virNWFilterDefPtr newNext_filter;
@@ -515,15 +515,13 @@ virNWFilterDetermineMissingVarsRec(virNWFilterDefPtr filter,
                     virNWFilterVarAccessPrint(rule->varAccess[j], &buf);
                     if (virBufferError(&buf)) {
                         virReportOOMError();
-                        rc = -1;
-                        break;
+                        return -1;
                     }
 
                     val = virNWFilterVarValueCreateSimpleCopyValue("1");
                     if (!val) {
                         virBufferFreeAndReset(&buf);
-                        rc = -1;
-                        break;
+                        return -1;
                     }
 
                     varAccess = virBufferContentAndReset(&buf);
@@ -532,21 +530,16 @@ virNWFilterDetermineMissingVarsRec(virNWFilterDefPtr filter,
                     VIR_FREE(varAccess);
                 }
             }
-            if (rc)
-                break;
         } else if (inc) {
             VIR_DEBUG("Following filter %s", inc->filterref);
             if (!(obj = virNWFilterObjListFindInstantiateFilter(driver->nwfilters,
-                                                                inc->filterref))) {
-                rc = -1;
-                break;
-            }
+                                                                inc->filterref)))
+                return -1;
 
             /* create a temporary hashmap for depth-first tree traversal */
             if (!(tmpvars = virNWFilterCreateVarsFrom(inc->params, vars))) {
-                rc = -1;
                 virNWFilterObjUnlock(obj);
-                break;
+                return -1;
             }
 
             next_filter = virNWFilterObjGetDef(obj);
@@ -571,10 +564,10 @@ virNWFilterDetermineMissingVarsRec(virNWFilterDefPtr filter,
 
             virNWFilterObjUnlock(obj);
             if (rc < 0)
-                break;
+                return -1;
         }
     }
-    return rc;
+    return 0;
 }
 
 
-- 
2.13.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux