]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Enable a subset of -Wextra
authorFrank Lichtenheld <frank@lichtenheld.com>
Tue, 23 Sep 2025 14:08:48 +0000 (16:08 +0200)
committerGert Doering <gert@greenie.muc.de>
Tue, 23 Sep 2025 14:11:45 +0000 (16:11 +0200)
- Includes fixes for
  - -Wimplicit-fallthrough=2
    (=3 is default but requires replacing all
     fallthrough comments)
  - -Wmissing-field-initializers
  - -Wold-style-declaration
- All other warnings that would need fixes are
  disabled for now.

Change-Id: I9ce664d073a4e6a6d433e9e6f986a5086dae8aa1
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1202
Message-Id: <20250923140854.21766-1-gert@greenie.muc.de>
URL: https://sourceforge.net/p/openvpn/mailman/message/59237558/
Signed-off-by: Gert Doering <gert@greenie.muc.de>
CMakeLists.txt
configure.ac
src/openvpn/misc.c
src/openvpn/tun.c
src/tapctl/tap.c
tests/unit_tests/openvpn/test_pkt.c

index f027b01037e08367fea6845bc6a8207aee348236..fdc01620b3e730ab3a6e1d7353d6e169cf1b7774 100644 (file)
@@ -114,7 +114,14 @@ else ()
     check_and_add_compiler_flag(-Wstrict-prototypes StrictPrototypes)
     check_and_add_compiler_flag(-Wold-style-definition OldStyleDefinition)
     # We are not ready for this
-    #add_compile_options(-Wconversion -Wno-sign-conversion -Wsign-compare)
+    #add_compile_options(-Wconversion -Wno-sign-conversion)
+    add_compile_options(-Wextra -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter)
+    # clang doesn't have the different levels but also doesn't include it in -Wextra
+    check_and_add_compiler_flag(-Wimplicit-fallthrough=2 GCCImplicitFallthrough)
+    if (WIN32)
+        # Not sure how to deal with GetProcAddress
+        add_compile_options(-Wno-cast-function-type)
+    endif ()
     if (USE_WERROR)
         add_compile_options(-Werror)
     endif ()
index 0fc21ee524f54a7752aff14f919b5354923f5555..c2feeea752116f0dde1b1b60f87d94745f4f0854 100644 (file)
@@ -1398,6 +1398,13 @@ ACL_CHECK_ADD_COMPILE_FLAGS([-Wno-stringop-truncation])
 ACL_CHECK_ADD_COMPILE_FLAGS([-Wstrict-prototypes])
 ACL_CHECK_ADD_COMPILE_FLAGS([-Wold-style-definition])
 ACL_CHECK_ADD_COMPILE_FLAGS([-Wall])
+ACL_CHECK_ADD_COMPILE_FLAGS([-Wextra -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter])
+# clang doesn't have the different levels but also doesn't include it in -Wextra
+ACL_CHECK_ADD_COMPILE_FLAGS([-Wimplicit-fallthrough=2])
+if test "${WIN32}" = "yes"; then
+        # Not sure how to deal with GetProcAddress
+       ACL_CHECK_ADD_COMPILE_FLAGS([-Wno-cast-function-type])
+fi
 
 if test "${enable_pedantic}" = "yes"; then
        enable_strict="yes"
index e0b5da1b48a6520eb2abdb4c1ba7d2df5651fa0f..d3d316dcb6bd052926da7f97e4cf5e72ce7e3b0c 100644 (file)
@@ -733,7 +733,7 @@ validate_peer_info_line(char *line)
                 {
                     return false;
                 }
-
+                /* Intentional [[fallthrough]]; */
             case 2:
                 /* after the '=', replace non-printable or shell meta with '_' */
                 if (!isprint(c) || isspace(c) || c == '$' || c == '(' || c == '`')
index 9618301bcad3e864d5647feec04dfcbdc7ab6cd5..c213c4b44b10c1bb9480879e2158a3e017b51c92 100644 (file)
@@ -84,10 +84,10 @@ print_tun_backend_driver(enum tun_driver_type driver)
 
 #ifdef _WIN32
 
-const static GUID GUID_DEVCLASS_NET = {
+static const GUID GUID_DEVCLASS_NET = {
     0x4d36e972L, 0xe325, 0x11ce, { 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18 }
 };
-const static GUID GUID_DEVINTERFACE_NET = {
+static const GUID GUID_DEVINTERFACE_NET = {
     0xcac88484, 0x7515, 0x4c03, { 0x82, 0xe6, 0x71, 0xa8, 0x7a, 0xba, 0xc3, 0x61 }
 };
 
index b633e77641b671d3cf67a55f39e944275c37324d..973160205af7135736b1d94bdbaf12e338ac1653 100644 (file)
 #endif
 
 
-const static GUID GUID_DEVCLASS_NET = {
+static const GUID GUID_DEVCLASS_NET = {
     0x4d36e972L, 0xe325, 0x11ce, { 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18 }
 };
 
-const static WCHAR szAdapterRegKeyPathTemplate[] =
+static const WCHAR szAdapterRegKeyPathTemplate[] =
     L"SYSTEM\\CurrentControlSet\\Control\\Network\\%ls\\%ls\\Connection";
 #define ADAPTER_REGKEY_PATH_MAX                                                                \
     (_countof(L"SYSTEM\\CurrentControlSet\\Control\\Network\\") - 1 + 38 + _countof(L"\\") - 1 \
index b5211cdd636272885904ec5aac69f5021493ce9a..1423d469c2887386ea4d16eebdfaaebb860db58c 100644 (file)
@@ -164,7 +164,7 @@ struct tls_auth_standalone
 init_tas_auth(int key_direction)
 {
     struct tls_auth_standalone tas = { 0 };
-    struct frame frame = { { .headroom = 200, .payload_size = 1400 }, 0 };
+    struct frame frame = { .buf = { .headroom = 200, .payload_size = 1400 }, 0 };
     tas.frame = frame;
 
     tas.tls_wrap.mode = TLS_WRAP_AUTH;
@@ -591,7 +591,7 @@ test_generate_reset_packet_plain(void **ut_state)
     enum first_packet_verdict verdict;
 
     tas.tls_wrap.mode = TLS_WRAP_NONE;
-    struct frame frame = { { .headroom = 200, .payload_size = 1400 }, 0 };
+    struct frame frame = { .buf = { .headroom = 200, .payload_size = 1400 }, 0 };
     tas.frame = frame;
     tas.workbuf = alloc_buf(1600);