diff options
author | Anoop C S <anoopcs@redhat.com> | 2016-08-11 19:27:17 +0530 |
---|---|---|
committer | Andreas Schneider <asn@samba.org> | 2016-08-12 08:29:32 +0200 |
commit | 69b89aa9d0847ba7238963c0dafef41d691c52cd (patch) | |
tree | 7dc65fc792ec6df92033490fe0ab594017923aea /src | |
parent | 44f7e09b5213a5ae91fb8e67262ac4a7e1bdf528 (diff) | |
download | socket_wrapper-69b89aa9d0847ba7238963c0dafef41d691c52cd.tar.gz socket_wrapper-69b89aa9d0847ba7238963c0dafef41d691c52cd.tar.xz socket_wrapper-69b89aa9d0847ba7238963c0dafef41d691c52cd.zip |
swrap: Simplify swrap_remove_stale by early return
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/socket_wrapper.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index ba289e6..e944a3b 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -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); } } |