swrap: Simplify swrap_remove_stale by early return
authorAnoop C S <anoopcs@redhat.com>
Thu, 11 Aug 2016 13:57:17 +0000 (19:27 +0530)
committerAndreas Schneider <asn@samba.org>
Fri, 12 Aug 2016 06:29:32 +0000 (08:29 +0200)
Pair-programmed-with: Michael Adam <obnox@samba.org>
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
src/socket_wrapper.c

index ba289e6fbaf96866a8467f708cf7a372d82fa739..e944a3b818b49bdf8fa559d0b57a6107e3174f25 100644 (file)
@@ -1469,23 +1469,25 @@ static void swrap_remove_stale(int fd)
        struct socket_info *si = find_socket_info(fd);
        struct socket_info_fd *fi;
 
-       if (si != NULL) {
-               for (fi = si->fds; fi; fi = fi->next) {
-                       if (fi->fd == fd) {
-                               SWRAP_LOG(SWRAP_LOG_TRACE, "remove stale wrapper for %d", fd);
-                               SWRAP_DLIST_REMOVE(si->fds, fi);
-                               free(fi);
-                               break;
-                       }
+       if (si == NULL) {
+               return;
+       }
+
+       for (fi = si->fds; fi; fi = fi->next) {
+               if (fi->fd == fd) {
+                       SWRAP_LOG(SWRAP_LOG_TRACE, "remove stale wrapper for %d", fd);
+                       SWRAP_DLIST_REMOVE(si->fds, fi);
+                       free(fi);
+                       break;
                }
+       }
 
-               if (si->fds == NULL) {
-                       SWRAP_DLIST_REMOVE(sockets, si);
-                       if (si->un_addr.sun_path[0] != '\0') {
-                               unlink(si->un_addr.sun_path);
-                       }
-                       free(si);
+       if (si->fds == NULL) {
+               SWRAP_DLIST_REMOVE(sockets, si);
+               if (si->un_addr.sun_path[0] != '\0') {
+                       unlink(si->un_addr.sun_path);
                }
+               free(si);
        }
 }