[SCM] Socket Wrapper Repository - branch master updated

Andreas Schneider asn at samba.org
Thu Jul 21 12:43:46 UTC 2022


The branch, master has been updated
       via  2e64ad0 gitlab-ci: Introduce stages
       via  ffa9e06 gitlab-ci: Fix formatting
       via  dfad2f7 Add editorconfig
       via  324c57a swrap: Remove _close symbol alias as this breaks 'make test' on FreeBSD
       via  9c3113d tests: Fix compiler warning that arrays might not be initialized
       via  04430cc cmake: Disable -Werror=strict-overflow till glibc is fixed
      from  088410e swrap: Don't pass NULL pointers to memcpy()

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


- Log -----------------------------------------------------------------
commit 2e64ad0aaf417ba22757634dd409e4ba93ddfbc7
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Mar 3 09:24:09 2022 +0100

    gitlab-ci: Introduce stages
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit ffa9e069202b71be737a05c9b7f30b4b6d3bc2c4
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Mar 3 09:18:11 2022 +0100

    gitlab-ci: Fix formatting
    
    Complaints from yamllint.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit dfad2f7574d5b62c1f03a6bb64631cde1aa350a9
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Mar 3 09:22:01 2022 +0100

    Add editorconfig
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 324c57ae5d086017f7c226c22eca8eeee0d27d71
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jul 21 08:59:32 2022 +0200

    swrap: Remove _close symbol alias as this breaks 'make test' on FreeBSD
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 9c3113d2c30c65ac01f0a795e9e9b0df53abcce2
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jul 21 07:33:11 2022 +0200

    tests: Fix compiler warning that arrays might not be initialized
    
    tests/test_echo_tcp_sendmsg_recvmsg_fd.c: In function 'test_tcp_sendmsg_recvmsg_fd_mixed':
    tests/test_echo_tcp_sendmsg_recvmsg_fd.c:477:9: error: '<unknown>' may be used uninitialized [-Werror=maybe-uninitialized]
      477 |         test_tcp_sendmsg_recvmsg_fd_array(fd_array, num_fds);
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    tests/test_echo_tcp_sendmsg_recvmsg_fd.c:103:13: note: by argument 1 of type 'const int *' to 'test_tcp_sendmsg_recvmsg_fd_array' declared here
      103 | static void test_tcp_sendmsg_recvmsg_fd_array(const int *fds, size_t num_fds)
          |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 04430ccf0f5ce4bbb48638c53cde66c9a7bb2e3e
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jul 21 07:50:27 2022 +0200

    cmake: Disable -Werror=strict-overflow till glibc is fixed
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

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

Summary of changes:
 .editorconfig                            |  23 +++
 .gitlab-ci.yml                           | 238 +++++++++++++++++--------------
 CompilerChecks.cmake                     |   7 +-
 src/socket_wrapper.c                     |   5 +-
 tests/test_echo_tcp_sendmsg_recvmsg_fd.c |  11 +-
 5 files changed, 166 insertions(+), 118 deletions(-)
 create mode 100644 .editorconfig


Changeset truncated at 500 lines:

diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..bbe1bd5
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,23 @@
+root = true
+
+[*]
+charset = utf-8
+max_line_length = 80
+end_of_line = lf
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[*.{c,h}]
+indent_style = tab
+indent_size = 8
+tab_width = 8
+
+[*.cmake]
+indent_style = space
+indent_size = 4
+tab_width = 4
+
+[CMake*]
+indent_style = space
+indent_size = 4
+tab_width = 4
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c4dd3ce..d5dc461 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,3 +1,4 @@
+---
 variables:
   BUILD_IMAGES_PROJECT: cmocka/gitlab-build-images
   FEDORA_BUILD: buildenv-fedora
@@ -6,18 +7,24 @@ variables:
   MINGW_BUILD: buildenv-mingw
   UBUNTU_BUILD: buildenv-ubuntu
 
+stages:
+  - build
+  - test
+  - analysis
+
 centos7/x86_64:
+  stage: test
   image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$CENTOS7_BUILD
   script:
-  - mkdir -p obj && cd obj && cmake3
-    -DCMAKE_BUILD_TYPE=RelWithDebInfo
-    -DPICKY_DEVELOPER=ON
-    -DUNIT_TESTING=ON .. &&
-    make -j$(nproc) && ctest --output-on-failure
+    - mkdir -p obj && cd obj && cmake3
+      -DCMAKE_BUILD_TYPE=RelWithDebInfo
+      -DPICKY_DEVELOPER=ON
+      -DUNIT_TESTING=ON .. &&
+      make -j$(nproc) && ctest --output-on-failure
   tags:
-  - shared
+    - shared
   except:
-  - tags
+    - tags
   artifacts:
     expire_in: 1 week
     when: on_failure
@@ -25,17 +32,18 @@ centos7/x86_64:
       - obj/
 
 fedora/x86_64:
+  stage: test
   image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
   script:
-  - mkdir -p obj && cd obj && cmake
-    -DCMAKE_BUILD_TYPE=RelWithDebInfo
-    -DPICKY_DEVELOPER=ON
-    -DUNIT_TESTING=ON .. &&
-    make -j$(nproc) && ctest --output-on-failure
+    - mkdir -p obj && cd obj && cmake
+      -DCMAKE_BUILD_TYPE=RelWithDebInfo
+      -DPICKY_DEVELOPER=ON
+      -DUNIT_TESTING=ON .. &&
+      make -j$(nproc) && ctest --output-on-failure
   tags:
-  - shared
+    - shared
   except:
-  - tags
+    - tags
   artifacts:
     expire_in: 1 week
     when: on_failure
@@ -43,17 +51,18 @@ fedora/x86_64:
       - obj/
 
 fedora/address-sanitizer:
+  stage: build
   image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
   script:
-  - mkdir -p obj && cd obj && cmake
-    -DCMAKE_BUILD_TYPE=AddressSanitizer
-    -DPICKY_DEVELOPER=ON
-    -DUNIT_TESTING=ON .. &&
-    make -j$(nproc) && ctest --output-on-failure
+    - mkdir -p obj && cd obj && cmake
+      -DCMAKE_BUILD_TYPE=AddressSanitizer
+      -DPICKY_DEVELOPER=ON
+      -DUNIT_TESTING=ON .. &&
+      make -j$(nproc) && ctest --output-on-failure
   tags:
-  - shared
+    - shared
   except:
-  - tags
+    - tags
   artifacts:
     expire_in: 1 week
     when: on_failure
@@ -61,16 +70,17 @@ fedora/address-sanitizer:
       - obj/
 
 fedora/undefined-sanitizer:
+  stage: analysis
   image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
   script:
-  - mkdir -p obj && cd obj && cmake
-    -DCMAKE_BUILD_TYPE=UndefinedSanitizer
-    -DUNIT_TESTING=ON ..
-    && make -j$(nproc) && ctest --output-on-failure
+    - mkdir -p obj && cd obj && cmake
+      -DCMAKE_BUILD_TYPE=UndefinedSanitizer
+      -DUNIT_TESTING=ON ..
+      && make -j$(nproc) && ctest --output-on-failure
   tags:
-  - shared
+    - shared
   except:
-  - tags
+    - tags
   artifacts:
     expire_in: 1 week
     when: on_failure
@@ -81,17 +91,18 @@ fedora/undefined-sanitizer:
 #
 # fedora/thread-sanitizer:
 tumbleweed/thread-sanitizer:
+  stage: analysis
   image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD
   script:
-  - mkdir -p obj && cd obj && cmake
-    -DCMAKE_BUILD_TYPE=ThreadSanitizer
-    -DPICKY_DEVELOPER=ON
-    -DUNIT_TESTING=ON .. &&
-    make -j$(nproc) && ctest --output-on-failure
+    - mkdir -p obj && cd obj && cmake
+      -DCMAKE_BUILD_TYPE=ThreadSanitizer
+      -DPICKY_DEVELOPER=ON
+      -DUNIT_TESTING=ON .. &&
+      make -j$(nproc) && ctest --output-on-failure
   tags:
-  - shared
+    - shared
   except:
-  - tags
+    - tags
   artifacts:
     expire_in: 1 week
     when: on_failure
@@ -99,30 +110,32 @@ tumbleweed/thread-sanitizer:
       - obj/
 
 fedora/csbuild:
+  stage: analysis
   image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
   script:
-  - |
-    if [[ -z "$CI_COMMIT_BEFORE_SHA" ]]; then
-        export CI_COMMIT_BEFORE_SHA=$(git rev-parse "${CI_COMMIT_SHA}~20")
-    fi
+    - |
+      if [[ -z "$CI_COMMIT_BEFORE_SHA" ]]; then
+          export CI_COMMIT_BEFORE_SHA=$(git rev-parse "${CI_COMMIT_SHA}~20")
+      fi
 
-    # Check if the commit exists in this branch
-    # This is not the case for a force push
-    git branch --contains $CI_COMMIT_BEFORE_SHA 2>/dev/null || export CI_COMMIT_BEFORE_SHA=$(git rev-parse "${CI_COMMIT_SHA}~20")
+      # Check if the commit exists in this branch
+      # This is not the case for a force push
+      git branch --contains $CI_COMMIT_BEFORE_SHA 2>/dev/null ||
+        export CI_COMMIT_BEFORE_SHA=$(git rev-parse "${CI_COMMIT_SHA}~20")
 
-    export CI_COMMIT_RANGE="$CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA"
+      export CI_COMMIT_RANGE="$CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA"
 
-  - csbuild
-    --build-dir=obj-csbuild
-    --prep-cmd="cmake -DCMAKE_BUILD_TYPE=Debug -DPICKY_DEVELOPER=ON -DUNIT_TESTING=ON @SRCDIR@"
-    --build-cmd "make clean && make -j$(nproc)"
-    --git-commit-range $CI_COMMIT_RANGE
-    --color
-    --print-current --print-fixed
+    - csbuild
+      --build-dir=obj-csbuild
+      --prep-cmd="cmake -DCMAKE_BUILD_TYPE=Debug -DPICKY_DEVELOPER=ON -DUNIT_TESTING=ON @SRCDIR@"
+      --build-cmd "make clean && make -j$(nproc)"
+      --git-commit-range $CI_COMMIT_RANGE
+      --color
+      --print-current --print-fixed
   tags:
-  - shared
+    - shared
   except:
-  - tags
+    - tags
   artifacts:
     expire_in: 1 week
     when: on_failure
@@ -130,21 +143,22 @@ fedora/csbuild:
       - obj-csbuild/
 
 freebsd/x86_64:
+  stage: test
   image:
   script:
-  - mkdir -p obj && cd obj && cmake
-    -DCMAKE_BUILD_TYPE=RelWithDebInfo
-    -DPICKY_DEVELOPER=ON
-    -DUNIT_TESTING=ON .. &&
-    make && ctest --output-on-failure
+    - mkdir -p obj && cd obj && cmake
+      -DCMAKE_BUILD_TYPE=RelWithDebInfo
+      -DPICKY_DEVELOPER=ON
+      -DUNIT_TESTING=ON .. &&
+      make && ctest --output-on-failure
   tags:
-  - freebsd
+    - freebsd
   except:
-  - tags
+    - tags
   only:
-  - branches at cwrap/socket_wrapper
-  - branches at cryptomilk/socket_wrapper
-  - branches at metze/socket_wrapper
+    - branches at cwrap/socket_wrapper
+    - branches at cryptomilk/socket_wrapper
+    - branches at metze/socket_wrapper
   artifacts:
     expire_in: 1 week
     when: on_failure
@@ -152,17 +166,18 @@ freebsd/x86_64:
       - obj/
 
 tumbleweed/x86_64/gcc:
+  stage: test
   image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD
   script:
-  - mkdir -p obj && cd obj && cmake
-    -DCMAKE_BUILD_TYPE=RelWithDebInfo
-    -DPICKY_DEVELOPER=ON
-    -DUNIT_TESTING=ON .. &&
-    make -j$(nproc) && ctest --output-on-failure
+    - mkdir -p obj && cd obj && cmake
+      -DCMAKE_BUILD_TYPE=RelWithDebInfo
+      -DPICKY_DEVELOPER=ON
+      -DUNIT_TESTING=ON .. &&
+      make -j$(nproc) && ctest --output-on-failure
   tags:
-  - shared
+    - shared
   except:
-  - tags
+    - tags
   artifacts:
     expire_in: 1 week
     when: on_failure
@@ -170,18 +185,19 @@ tumbleweed/x86_64/gcc:
       - obj/
 
 tumbleweed/x86_64/gcc7:
+  stage: test
   image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD
   script:
-  - mkdir -p obj && cd obj && cmake
-    -DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7
-    -DCMAKE_BUILD_TYPE=RelWithDebInfo
-    -DPICKY_DEVELOPER=ON
-    -DUNIT_TESTING=ON .. &&
-    make -j$(nproc) && ctest --output-on-failure
+    - mkdir -p obj && cd obj && cmake
+      -DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7
+      -DCMAKE_BUILD_TYPE=RelWithDebInfo
+      -DPICKY_DEVELOPER=ON
+      -DUNIT_TESTING=ON .. &&
+      make -j$(nproc) && ctest --output-on-failure
   tags:
-  - shared
+    - shared
   except:
-  - tags
+    - tags
   artifacts:
     expire_in: 1 week
     when: on_failure
@@ -189,18 +205,19 @@ tumbleweed/x86_64/gcc7:
       - obj/
 
 tumbleweed/x86_64/clang:
+  stage: test
   image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD
   script:
-  - mkdir -p obj && cd obj && cmake
-    -DCMAKE_BUILD_TYPE=RelWithDebInfo
-    -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
-    -DPICKY_DEVELOPER=ON
-    -DUNIT_TESTING=ON .. &&
-    make -j$(nproc) && ctest --output-on-failure
+    - mkdir -p obj && cd obj && cmake
+      -DCMAKE_BUILD_TYPE=RelWithDebInfo
+      -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
+      -DPICKY_DEVELOPER=ON
+      -DUNIT_TESTING=ON .. &&
+      make -j$(nproc) && ctest --output-on-failure
   tags:
-  - shared
+    - shared
   except:
-  - tags
+    - tags
   artifacts:
     expire_in: 1 week
     when: on_failure
@@ -208,20 +225,21 @@ tumbleweed/x86_64/clang:
       - obj/
 
 tumbleweed/static-analysis:
+  stage: analysis
   image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD
   script:
-  - export CCC_CC=clang
-  - export CCC_CXX=clang++
-  - mkdir -p obj && cd obj && scan-build cmake
-    -DCMAKE_BUILD_TYPE=Debug
-    -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
-    -DPICKY_DEVELOPER=ON
-    -DUNIT_TESTING=ON .. &&
-    scan-build --status-bugs -o scan make -j$(nproc)
+    - export CCC_CC=clang
+    - export CCC_CXX=clang++
+    - mkdir -p obj && cd obj && scan-build cmake
+      -DCMAKE_BUILD_TYPE=Debug
+      -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
+      -DPICKY_DEVELOPER=ON
+      -DUNIT_TESTING=ON .. &&
+      scan-build --status-bugs -o scan make -j$(nproc)
   tags:
-  - shared
+    - shared
   except:
-  - tags
+    - tags
   artifacts:
     expire_in: 1 week
     when: on_failure
@@ -229,18 +247,19 @@ tumbleweed/static-analysis:
       - obj/scan
 
 tumbleweed/helgrind:
+  stage: analysis
   image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD
   script:
-  - mkdir -p obj && cd obj && cmake
-    -DCMAKE_BUILD_TYPE=Debug
-    -DPICKY_DEVELOPER=ON
-    -DUNIT_TESTING=ON
-    -DHELGRIND_TESTING=ON .. &&
-    make -j$(nproc) && ctest --output-on-failure
+    - mkdir -p obj && cd obj && cmake
+      -DCMAKE_BUILD_TYPE=Debug
+      -DPICKY_DEVELOPER=ON
+      -DUNIT_TESTING=ON
+      -DHELGRIND_TESTING=ON .. &&
+      make -j$(nproc) && ctest --output-on-failure
   tags:
-  - shared
+    - shared
   except:
-  - tags
+    - tags
   artifacts:
     expire_in: 1 week
     when: on_failure
@@ -251,17 +270,18 @@ tumbleweed/helgrind:
       - $VALGRIND_SUPPORTS_FORKED_MUTEXES == "yes"
 
 ubuntu/x86_64:
+  stage: test
   image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$UBUNTU_BUILD
   script:
-  - mkdir -p obj && cd obj && cmake
-    -DCMAKE_BUILD_TYPE=RelWithDebInfo
-    -DPICKY_DEVELOPER=ON
-    -DUNIT_TESTING=ON .. &&
-    make -j$(nproc) && ctest --output-on-failure
+    - mkdir -p obj && cd obj && cmake
+      -DCMAKE_BUILD_TYPE=RelWithDebInfo
+      -DPICKY_DEVELOPER=ON
+      -DUNIT_TESTING=ON .. &&
+      make -j$(nproc) && ctest --output-on-failure
   tags:
-  - shared
+    - shared
   except:
-  - tags
+    - tags
   artifacts:
     expire_in: 1 week
     when: on_failure
diff --git a/CompilerChecks.cmake b/CompilerChecks.cmake
index 4fa1a83..195d619 100644
--- a/CompilerChecks.cmake
+++ b/CompilerChecks.cmake
@@ -38,8 +38,11 @@ if (UNIX)
     add_c_compiler_flag("-Wuninitialized" SUPPORTED_COMPILER_FLAGS)
     add_c_compiler_flag("-Werror=uninitialized" SUPPORTED_COMPILER_FLAGS)
     add_c_compiler_flag("-Wimplicit-fallthrough" SUPPORTED_COMPILER_FLAGS)
-    add_c_compiler_flag("-Werror=strict-overflow" SUPPORTED_COMPILER_FLAGS)
-    add_c_compiler_flag("-Wstrict-overflow=2" SUPPORTED_COMPILER_FLAGS)
+    # FIXME: We can't use this as there is a glibc bug in socket.h
+    # https://bugzilla.redhat.com/show_bug.cgi?id=2047022
+    # https://sourceware.org/bugzilla/show_bug.cgi?id=28846
+    #add_c_compiler_flag("-Werror=strict-overflow" SUPPORTED_COMPILER_FLAGS)
+    #add_c_compiler_flag("-Wstrict-overflow=2" SUPPORTED_COMPILER_FLAGS)
     add_c_compiler_flag("-Wno-format-zero-length" SUPPORTED_COMPILER_FLAGS)
 
     check_c_compiler_flag("-Wformat" REQUIRED_FLAGS_WFORMAT)
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 8141b8b..ef87519 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -7851,8 +7851,8 @@ void swrap_destructor(void)
  * related syscalls also with the '_' prefix.
  *
  * This is tested in Samba's 'make test',
- * there we noticed that providing '_read'
- * and '_open' would cause errors, which
+ * there we noticed that providing '_read',
+ * '_open' and '_close' would cause errors, which
  * means we skip '_read', '_write' and
  * all non socket related calls without
  * further analyzing the problem.
@@ -7865,7 +7865,6 @@ SWRAP_SYMBOL_ALIAS(accept4, _accept4);
 #endif
 SWRAP_SYMBOL_ALIAS(accept, _accept);
 SWRAP_SYMBOL_ALIAS(bind, _bind);
-SWRAP_SYMBOL_ALIAS(close, _close);
 SWRAP_SYMBOL_ALIAS(connect, _connect);
 SWRAP_SYMBOL_ALIAS(dup, _dup);
 SWRAP_SYMBOL_ALIAS(dup2, _dup2);
diff --git a/tests/test_echo_tcp_sendmsg_recvmsg_fd.c b/tests/test_echo_tcp_sendmsg_recvmsg_fd.c
index 215d5ff..e6892e6 100644
--- a/tests/test_echo_tcp_sendmsg_recvmsg_fd.c
+++ b/tests/test_echo_tcp_sendmsg_recvmsg_fd.c
@@ -320,6 +320,9 @@ static void test_tcp_sendmsg_recvmsg_fd_different(size_t num_fds)
 	int fd_array[num_fds];
 	size_t idx;
 
+	assert_int_not_equal(num_fds, 0);
+	memset(fd_array, -1, sizeof(fd_array));
+
 	for (idx = 0; idx < num_fds; idx++) {
 		struct torture_address addr = {
 			.sa_socklen = sizeof(struct sockaddr_in),
@@ -388,10 +391,10 @@ static void test_tcp_sendmsg_recvmsg_fd_mixed(size_t num_fds)
 	int close_array[num_fds];
 	size_t idx;
 
-	for (idx = 0; idx < num_fds; idx++) {
-		fd_array[idx] = -1;
-		close_array[idx] = -1;
-	}
+	assert_int_not_equal(num_fds, 0);
+
+	memset(fd_array, -1, sizeof(fd_array));
+	memset(close_array, -1, sizeof(fd_array));
 
 	/*
 	 * We send


-- 
Socket Wrapper Repository



More information about the samba-cvs mailing list