Skip to content

Commit 45eb7e1

Browse files
flichtenheldcron2
authored andcommitted
Enable a subset of -Wextra
- 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 <[email protected]> Acked-by: Gert Doering <[email protected]> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1202 Message-Id: <[email protected]> URL: https://sourceforge.net/p/openvpn/mailman/message/59237558/ Signed-off-by: Gert Doering <[email protected]>
1 parent 9bfd4d2 commit 45eb7e1

File tree

6 files changed

+22
-8
lines changed

6 files changed

+22
-8
lines changed

CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,14 @@ else ()
114114
check_and_add_compiler_flag(-Wstrict-prototypes StrictPrototypes)
115115
check_and_add_compiler_flag(-Wold-style-definition OldStyleDefinition)
116116
# We are not ready for this
117-
#add_compile_options(-Wconversion -Wno-sign-conversion -Wsign-compare)
117+
#add_compile_options(-Wconversion -Wno-sign-conversion)
118+
add_compile_options(-Wextra -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter)
119+
# clang doesn't have the different levels but also doesn't include it in -Wextra
120+
check_and_add_compiler_flag(-Wimplicit-fallthrough=2 GCCImplicitFallthrough)
121+
if (WIN32)
122+
# Not sure how to deal with GetProcAddress
123+
add_compile_options(-Wno-cast-function-type)
124+
endif ()
118125
if (USE_WERROR)
119126
add_compile_options(-Werror)
120127
endif ()

configure.ac

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,6 +1398,13 @@ ACL_CHECK_ADD_COMPILE_FLAGS([-Wno-stringop-truncation])
13981398
ACL_CHECK_ADD_COMPILE_FLAGS([-Wstrict-prototypes])
13991399
ACL_CHECK_ADD_COMPILE_FLAGS([-Wold-style-definition])
14001400
ACL_CHECK_ADD_COMPILE_FLAGS([-Wall])
1401+
ACL_CHECK_ADD_COMPILE_FLAGS([-Wextra -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter])
1402+
# clang doesn't have the different levels but also doesn't include it in -Wextra
1403+
ACL_CHECK_ADD_COMPILE_FLAGS([-Wimplicit-fallthrough=2])
1404+
if test "${WIN32}" = "yes"; then
1405+
# Not sure how to deal with GetProcAddress
1406+
ACL_CHECK_ADD_COMPILE_FLAGS([-Wno-cast-function-type])
1407+
fi
14011408

14021409
if test "${enable_pedantic}" = "yes"; then
14031410
enable_strict="yes"

src/openvpn/misc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ validate_peer_info_line(char *line)
733733
{
734734
return false;
735735
}
736-
736+
/* Intentional [[fallthrough]]; */
737737
case 2:
738738
/* after the '=', replace non-printable or shell meta with '_' */
739739
if (!isprint(c) || isspace(c) || c == '$' || c == '(' || c == '`')

src/openvpn/tun.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ print_tun_backend_driver(enum tun_driver_type driver)
8484

8585
#ifdef _WIN32
8686

87-
const static GUID GUID_DEVCLASS_NET = {
87+
static const GUID GUID_DEVCLASS_NET = {
8888
0x4d36e972L, 0xe325, 0x11ce, { 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18 }
8989
};
90-
const static GUID GUID_DEVINTERFACE_NET = {
90+
static const GUID GUID_DEVINTERFACE_NET = {
9191
0xcac88484, 0x7515, 0x4c03, { 0x82, 0xe6, 0x71, 0xa8, 0x7a, 0xba, 0xc3, 0x61 }
9292
};
9393

src/tapctl/tap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@
4040
#endif
4141

4242

43-
const static GUID GUID_DEVCLASS_NET = {
43+
static const GUID GUID_DEVCLASS_NET = {
4444
0x4d36e972L, 0xe325, 0x11ce, { 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18 }
4545
};
4646

47-
const static WCHAR szAdapterRegKeyPathTemplate[] =
47+
static const WCHAR szAdapterRegKeyPathTemplate[] =
4848
L"SYSTEM\\CurrentControlSet\\Control\\Network\\%ls\\%ls\\Connection";
4949
#define ADAPTER_REGKEY_PATH_MAX \
5050
(_countof(L"SYSTEM\\CurrentControlSet\\Control\\Network\\") - 1 + 38 + _countof(L"\\") - 1 \

tests/unit_tests/openvpn/test_pkt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ struct tls_auth_standalone
164164
init_tas_auth(int key_direction)
165165
{
166166
struct tls_auth_standalone tas = { 0 };
167-
struct frame frame = { { .headroom = 200, .payload_size = 1400 }, 0 };
167+
struct frame frame = { .buf = { .headroom = 200, .payload_size = 1400 }, 0 };
168168
tas.frame = frame;
169169

170170
tas.tls_wrap.mode = TLS_WRAP_AUTH;
@@ -591,7 +591,7 @@ test_generate_reset_packet_plain(void **ut_state)
591591
enum first_packet_verdict verdict;
592592

593593
tas.tls_wrap.mode = TLS_WRAP_NONE;
594-
struct frame frame = { { .headroom = 200, .payload_size = 1400 }, 0 };
594+
struct frame frame = { .buf = { .headroom = 200, .payload_size = 1400 }, 0 };
595595
tas.frame = frame;
596596
tas.workbuf = alloc_buf(1600);
597597

0 commit comments

Comments
 (0)