[libvirt PATCH v2 10/13] virNetlinkEventAddClient: Remove goto

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

 



Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx>
---
 src/util/virnetlink.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
index 3216765492..c6c8c33c7c 100644
--- a/src/util/virnetlink.c
+++ b/src/util/virnetlink.c
@@ -1114,7 +1114,8 @@ virNetlinkEventAddClient(virNetlinkEventHandleCallback handleCB,
                          unsigned int protocol)
 {
     size_t i;
-    int r, ret = -1;
+    int r = -1;
+    int ret = -1;
     virNetlinkEventSrvPrivate *srv = NULL;
 
     if (protocol >= MAX_LINKS)
@@ -1132,24 +1133,25 @@ virNetlinkEventAddClient(virNetlinkEventHandleCallback handleCB,
 
     VIR_DEBUG("adding client: %d.", nextWatch);
 
-    r = 0;
     /* first try to re-use deleted free slots */
     for (i = 0; i < srv->handlesCount; i++) {
         if (srv->handles[i].deleted == VIR_NETLINK_HANDLE_DELETED) {
             r = i;
-            goto addentry;
+            break;
         }
     }
-    /* Resize the eventLoop array if needed */
-    if (srv->handlesCount == srv->handlesAlloc) {
-        VIR_DEBUG("Used %zu handle slots, adding at least %d more",
-                  srv->handlesAlloc, NETLINK_EVENT_ALLOC_EXTENT);
-        VIR_RESIZE_N(srv->handles, srv->handlesAlloc,
-                     srv->handlesCount, NETLINK_EVENT_ALLOC_EXTENT);
+
+    if (r < 0) {
+        /* Resize the eventLoop array if needed */
+        if (srv->handlesCount == srv->handlesAlloc) {
+            VIR_DEBUG("Used %zu handle slots, adding at least %d more",
+                      srv->handlesAlloc, NETLINK_EVENT_ALLOC_EXTENT);
+            VIR_RESIZE_N(srv->handles, srv->handlesAlloc,
+                         srv->handlesCount, NETLINK_EVENT_ALLOC_EXTENT);
+        }
+        r = srv->handlesCount++;
     }
-    r = srv->handlesCount++;
 
- addentry:
     srv->handles[r].watch    = nextWatch;
     srv->handles[r].handleCB = handleCB;
     srv->handles[r].removeCB = removeCB;
-- 
2.31.1




[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