[SCM] Socket Wrapper Repository - branch master updated

Andreas Schneider asn at samba.org
Thu Jul 27 07:55:05 UTC 2017


The branch, master has been updated
       via  ceb1767 swrap: Suppress intentional fall through warning
      from  9088344 swrap: Add fopen64() on systems which provide it

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


- Log -----------------------------------------------------------------
commit ceb17676cba178f56d00d21189c3f1765e5c2ae0
Author: Anoop C S <anoopcs at redhat.com>
Date:   Sat Jul 15 20:54:06 2017 +0530

    swrap: Suppress intentional fall through warning
    
    -Wimplicit-fallthrough compiler flag introduced with gcc v7
    results in the following warning during compilation:
    
    [  7%] Building C object src/CMakeFiles/socket_wrapper.dir/socket_wrapper.c.o
    src/socket_wrapper.c: In function ‘sockaddr_convert_to_un’:
    src/socket_wrapper.c:1846:18: warning: this statement may fall through [-Wimplicit-fallthrough=]
      case AF_UNSPEC: {
                      ^
    /src/socket_wrapper.c:1866:2: note: here
      case AF_INET:
      ^~~~
    
    Default level for -Wimplicit-fallthrough(which is 3) allows
    us to get rid of the above warning using specific comments
    made within switch cases matching the regular expressions
    outlined in gcc docs[1].
    
    But for us the presence of preprocessor directives in the
    vicinity of such comments nullifies its effect[2]. So our
    best bet would be to make use of the reliable fallthrough
    attribute and supress such warnings in future.
    
    [1] https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wimplicit-fallthrough
    [2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77817
    
    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>

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

Summary of changes:
 ConfigureChecks.cmake | 27 +++++++++++++++++++++++++++
 config.h.cmake        |  1 +
 src/socket_wrapper.c  | 16 +++++++++++-----
 3 files changed, 39 insertions(+), 5 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 0691c8a..cb2ea92 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -198,6 +198,33 @@ int main(void) {
 }" HAVE_DESTRUCTOR_ATTRIBUTE)
 
 check_c_source_compiles("
+#define FALL_THROUGH __attribute__((fallthrough))
+
+enum direction_e {
+    UP = 0,
+    DOWN,
+};
+
+int main(void) {
+    enum direction_e key = UP;
+    int i = 10;
+    int j = 0;
+
+    switch (key) {
+    case UP:
+        i = 5;
+        FALL_THROUGH;
+    case DOWN:
+        j = i * 2;
+        break;
+    default:
+        break;
+    }
+
+    return 0;
+}" HAVE_FALLTHROUGH_ATTRIBUTE)
+
+check_c_source_compiles("
 __thread int tls;
 
 int main(void) {
diff --git a/config.h.cmake b/config.h.cmake
index 2f494a4..b98ceff 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -62,6 +62,7 @@
 #cmakedefine HAVE_GCC_THREAD_LOCAL_STORAGE 1
 #cmakedefine HAVE_CONSTRUCTOR_ATTRIBUTE 1
 #cmakedefine HAVE_DESTRUCTOR_ATTRIBUTE 1
+#cmakedefine HAVE_FALLTHROUGH_ATTRIBUTE 1
 #cmakedefine HAVE_ADDRESS_SANITIZER_ATTRIBUTE 1
 #cmakedefine HAVE_SOCKADDR_STORAGE 1
 #cmakedefine HAVE_IPV6 1
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 395d0d7..29cd3f9 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -107,6 +107,12 @@ enum swrap_dbglvl_e {
 #define DESTRUCTOR_ATTRIBUTE
 #endif
 
+#ifdef HAVE_FALLTHROUGH_ATTRIBUTE
+#define FALL_THROUGH __attribute__ ((fallthrough))
+#else
+#define FALL_THROUGH
+#endif
+
 #ifdef HAVE_ADDRESS_SANITIZER_ATTRIBUTE
 #define DO_NOT_SANITIZE_ADDRESS_ATTRIBUTE __attribute__((no_sanitize_address))
 #else
@@ -587,7 +593,7 @@ static void *swrap_load_lib_handle(enum swrap_lib lib)
 
 	switch (lib) {
 	case SWRAP_LIBNSL:
-		/* FALL TROUGH */
+		FALL_THROUGH;
 	case SWRAP_LIBSOCKET:
 #ifdef HAVE_LIBSOCKET
 		handle = swrap.libc.socket_handle;
@@ -606,7 +612,7 @@ static void *swrap_load_lib_handle(enum swrap_lib lib)
 		}
 		break;
 #endif
-		/* FALL TROUGH */
+		FALL_THROUGH;
 	case SWRAP_LIBC:
 		handle = swrap.libc.handle;
 #ifdef LIBC_SO
@@ -1861,7 +1867,7 @@ static int sockaddr_convert_to_un(struct socket_info *si,
 		 * AF_UNSPEC is mapped to AF_INET and must be treated here.
 		 */
 
-		/* FALL THROUGH */
+		FALL_THROUGH;
 	}
 	case AF_INET:
 #ifdef HAVE_IPV6
@@ -2790,12 +2796,12 @@ static int swrap_socket(int family, int type, int protocol)
 		if (real_type == SOCK_STREAM) {
 			break;
 		}
-		/*fall through*/
+		FALL_THROUGH;
 	case 17:
 		if (real_type == SOCK_DGRAM) {
 			break;
 		}
-		/*fall through*/
+		FALL_THROUGH;
 	default:
 		errno = EPROTONOSUPPORT;
 		return -1;


-- 
Socket Wrapper Repository



More information about the samba-cvs mailing list