[SCM] Socket Wrapper Repository - branch master updated

Michael Adam obnox at samba.org
Thu Jul 27 12:17:42 UTC 2017


The branch, master has been updated
       via  fafd5ed cmake: Replace deprecated get_target_property()
       via  e961a1c swrap: Add common exit point to swrap_setsockopt
       via  070d84d swrap: Add common exit point to swrap_getsockopt
       via  b585bf0 swrap: Add common exit point to swrap_connect
       via  4c6082d swrap: Add common exit point to swrap_auto_bind
       via  d6253b3 swrap: Fix tab vs space in swrap_auto_bind
      from  ceb1767 swrap: Suppress intentional fall through warning

https://git.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit fafd5ed2dd89b7d951d70d0ac5585939cb2e4dcf
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jul 27 11:30:23 2017 +0200

    cmake: Replace deprecated get_target_property()
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit e961a1c8b8e03d9e8f070a686207740b486340ea
Author: Anoop C S <anoopcs at redhat.com>
Date:   Thu Jul 13 02:43:47 2017 +0200

    swrap: Add common exit point to swrap_setsockopt
    
    In preparation of thread safety.
    
    Signed-off-by: Anoop C S <anoopcs at redhat.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 070d84d733369a4de8f2b840a1f92065e2f3473d
Author: Anoop C S <anoopcs at redhat.com>
Date:   Thu Jul 13 02:36:20 2017 +0200

    swrap: Add common exit point to swrap_getsockopt
    
    In preparation of thread safety.
    
    Signed-off-by: Anoop C S <anoopcs at redhat.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit b585bf0a24d19e03f5a9fdc51b6b1bc90e60ddd6
Author: Anoop C S <anoopcs at redhat.com>
Date:   Thu Jul 13 02:30:14 2017 +0200

    swrap: Add common exit point to swrap_connect
    
    In preparation of thread safety.
    
    Signed-off-by: Anoop C S <anoopcs at redhat.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 4c6082d88e1241fe678687fb0d19480e17e700e5
Author: Anoop C S <anoopcs at redhat.com>
Date:   Thu Jul 13 02:26:10 2017 +0200

    swrap: Add common exit point to swrap_auto_bind
    
    In preparation for thread safety.
    
    Signed-off-by: Anoop C S <anoopcs at redhat.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit d6253b326ee53c4278458fc425335b64519d93dd
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jul 13 02:22:14 2017 +0200

    swrap: Fix tab vs space in swrap_auto_bind
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 src/CMakeLists.txt   |  7 +---
 src/socket_wrapper.c | 98 +++++++++++++++++++++++++++++++++++-----------------
 2 files changed, 67 insertions(+), 38 deletions(-)


Changeset truncated at 500 lines:

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3b4d7d0..d96f773 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -23,9 +23,4 @@ set_target_properties(
         ${LIBRARY_SOVERSION}
 )
 
-# This needs to be at the end
-if (POLICY CMP0026)
-    cmake_policy(SET CMP0026 OLD)
-endif()
-get_target_property(SWRAP_LOCATION socket_wrapper LOCATION)
-set(SOCKET_WRAPPER_LOCATION ${SWRAP_LOCATION} PARENT_SCOPE)
+set(SOCKET_WRAPPER_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}socket_wrapper${CMAKE_SHARED_LIBRARY_SUFFIX}" PARENT_SCOPE)
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 29cd3f9..46fb683 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -3173,8 +3173,9 @@ static int swrap_auto_bind(int fd, struct socket_info *si, int family)
 			type = SOCKET_TYPE_CHAR_UDP;
 			break;
 		default:
-		    errno = ESOCKTNOSUPPORT;
-		    return -1;
+			errno = ESOCKTNOSUPPORT;
+			ret = -1;
+			goto done;
 		}
 
 		memset(&in, 0, sizeof(in));
@@ -3194,7 +3195,8 @@ static int swrap_auto_bind(int fd, struct socket_info *si, int family)
 
 		if (si->family != family) {
 			errno = ENETUNREACH;
-			return -1;
+			ret = -1;
+			goto done;
 		}
 
 		switch (si->type) {
@@ -3206,7 +3208,8 @@ static int swrap_auto_bind(int fd, struct socket_info *si, int family)
 			break;
 		default:
 			errno = ESOCKTNOSUPPORT;
-			return -1;
+			ret = -1;
+			goto done;
 		}
 
 		memset(&in6, 0, sizeof(in6));
@@ -3223,7 +3226,8 @@ static int swrap_auto_bind(int fd, struct socket_info *si, int family)
 #endif
 	default:
 		errno = ESOCKTNOSUPPORT;
-		return -1;
+		ret = -1;
+		goto done;
 	}
 
 	if (autobind_start > 60000) {
@@ -3239,7 +3243,7 @@ static int swrap_auto_bind(int fd, struct socket_info *si, int family)
 
 		ret = libc_bind(fd, &un_addr.sa.s, un_addr.sa_socklen);
 		if (ret == -1) {
-			return ret;
+			goto done;
 		}
 
 		si->un_addr = un_addr.sa.un;
@@ -3256,13 +3260,17 @@ static int swrap_auto_bind(int fd, struct socket_info *si, int family)
 					   socket_wrapper_default_iface(),
 					   0);
 		errno = ENFILE;
-		return -1;
+		ret = -1;
+		goto done;
 	}
 
 	si->family = family;
 	set_port(si->family, port, &si->myname);
 
-	return 0;
+	ret = 0;
+
+done:
+	return ret;
 }
 
 /****************************************************************************
@@ -3286,24 +3294,26 @@ static int swrap_connect(int s, const struct sockaddr *serv_addr,
 	if (si->bound == 0) {
 		ret = swrap_auto_bind(s, si, serv_addr->sa_family);
 		if (ret == -1) {
-			return -1;
+			goto done;
 		}
 	}
 
 	if (si->family != serv_addr->sa_family) {
 		errno = EINVAL;
-		return -1;
+		ret = -1;
+		goto done;
 	}
 
 	ret = sockaddr_convert_to_un(si, serv_addr,
 				     addrlen, &un_addr.sa.un, 0, &bcast);
 	if (ret == -1) {
-		return -1;
+		goto done;
 	}
 
 	if (bcast) {
 		errno = ENETUNREACH;
-		return -1;
+		ret = -1;
+		goto done;
 	}
 
 	if (si->type == SOCK_DGRAM) {
@@ -3363,6 +3373,7 @@ static int swrap_connect(int s, const struct sockaddr *serv_addr,
 		swrap_pcap_dump_packet(si, serv_addr, SWRAP_CONNECT_UNREACH, NULL, 0);
 	}
 
+done:
 	return ret;
 }
 
@@ -3831,6 +3842,7 @@ static int swrap_getsockopt(int s, int level, int optname,
 			    void *optval, socklen_t *optlen)
 {
 	struct socket_info *si = find_socket_info(s);
+	int ret;
 
 	if (!si) {
 		return libc_getsockopt(s,
@@ -3847,12 +3859,14 @@ static int swrap_getsockopt(int s, int level, int optname,
 			if (optval == NULL || optlen == NULL ||
 			    *optlen < (socklen_t)sizeof(int)) {
 				errno = EINVAL;
-				return -1;
+				ret = -1;
+				goto done;
 			}
 
 			*optlen = sizeof(int);
 			*(int *)optval = si->family;
-			return 0;
+			ret = 0;
+			goto done;
 #endif /* SO_DOMAIN */
 
 #ifdef SO_PROTOCOL
@@ -3860,29 +3874,34 @@ static int swrap_getsockopt(int s, int level, int optname,
 			if (optval == NULL || optlen == NULL ||
 			    *optlen < (socklen_t)sizeof(int)) {
 				errno = EINVAL;
-				return -1;
+				ret = -1;
+				goto done;
 			}
 
 			*optlen = sizeof(int);
 			*(int *)optval = si->protocol;
-			return 0;
+			ret = 0;
+			goto done;
 #endif /* SO_PROTOCOL */
 		case SO_TYPE:
 			if (optval == NULL || optlen == NULL ||
 			    *optlen < (socklen_t)sizeof(int)) {
 				errno = EINVAL;
-				return -1;
+				ret = -1;
+				goto done;
 			}
 
 			*optlen = sizeof(int);
 			*(int *)optval = si->type;
-			return 0;
+			ret = 0;
+			goto done;
 		default:
-			return libc_getsockopt(s,
-					       level,
-					       optname,
-					       optval,
-					       optlen);
+			ret = libc_getsockopt(s,
+					      level,
+					      optname,
+					      optval,
+					      optlen);
+			goto done;
 		}
 	} else if (level == IPPROTO_TCP) {
 		switch (optname) {
@@ -3896,13 +3915,15 @@ static int swrap_getsockopt(int s, int level, int optname,
 			if (optval == NULL || optlen == NULL ||
 			    *optlen < (socklen_t)sizeof(int)) {
 				errno = EINVAL;
-				return -1;
+				ret = -1;
+				goto done;
 			}
 
 			*optlen = sizeof(int);
 			*(int *)optval = si->tcp_nodelay;
 
-			return 0;
+			ret = 0;
+			goto done;
 #endif /* TCP_NODELAY */
 		default:
 			break;
@@ -3910,7 +3931,10 @@ static int swrap_getsockopt(int s, int level, int optname,
 	}
 
 	errno = ENOPROTOOPT;
-	return -1;
+	ret = -1;
+
+done:
+	return ret;
 }
 
 #ifdef HAVE_ACCEPT_PSOCKLEN_T
@@ -3930,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,
@@ -3958,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:
@@ -3985,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) {
@@ -3995,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,


-- 
Socket Wrapper Repository



More information about the samba-cvs mailing list