From e961a1c8b8e03d9e8f070a686207740b486340ea Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Thu, 13 Jul 2017 02:43:47 +0200 Subject: swrap: Add common exit point to swrap_setsockopt In preparation of thread safety. Signed-off-by: Anoop C S Reviewed-by: Andreas Schneider Reviewed-by: Michael Adam --- src/socket_wrapper.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index 21e2fc1..46fb683 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -3954,6 +3954,7 @@ static int swrap_setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen) { struct socket_info *si = find_socket_info(s); + int ret; if (!si) { return libc_setsockopt(s, @@ -3982,17 +3983,20 @@ static int swrap_setsockopt(int s, int level, int optname, if (optval == NULL || optlen == 0 || optlen < (socklen_t)sizeof(int)) { errno = EINVAL; - return -1; + ret = -1; + goto done; } i = *discard_const_p(int, optval); if (i != 0 && i != 1) { errno = EINVAL; - return -1; + ret = -1; + goto done; } si->tcp_nodelay = i; - return 0; + ret = 0; + goto done; } #endif /* TCP_NODELAY */ default: @@ -4009,7 +4013,8 @@ static int swrap_setsockopt(int s, int level, int optname, } #endif /* IP_PKTINFO */ } - return 0; + ret = 0; + goto done; #ifdef HAVE_IPV6 case AF_INET6: if (level == IPPROTO_IPV6) { @@ -4019,12 +4024,17 @@ static int swrap_setsockopt(int s, int level, int optname, } #endif /* IPV6_PKTINFO */ } - return 0; + ret = 0; + goto done; #endif default: errno = ENOPROTOOPT; - return -1; + ret = -1; + goto done; } + +done: + return ret; } int setsockopt(int s, int level, int optname, -- cgit