Skip to content

Commit 5d50583

Browse files
flichtenheldcron2
authored andcommitted
Enable -Wtype-limits by default (via -Wextra)
Removes a few smaller instances: - Fix return type check for socket() on Windows/Unixy - Ignore a few instances related to WSAWaitForMultipleEvents. The compiler says the check is currently useless, but we follow the API documentation. Change-Id: Iaabddb6f81cd94863291b193aae9d384a8f9d871 Signed-off-by: Frank Lichtenheld <[email protected]> Acked-by: Arne Schwabe <[email protected]> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1207 Message-Id: <[email protected]> URL: https://www.mail-archive.com/[email protected]/msg34317.html Signed-off-by: Gert Doering <[email protected]>
1 parent 7e0b68a commit 5d50583

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ else ()
114114
check_and_add_compiler_flag(-Wstrict-prototypes StrictPrototypes)
115115
check_and_add_compiler_flag(-Wold-style-definition OldStyleDefinition)
116116
add_compile_options(-Wconversion -Wno-sign-conversion)
117-
add_compile_options(-Wextra -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter)
117+
add_compile_options(-Wextra -Wno-sign-compare -Wno-unused-parameter)
118118
# clang doesn't have the different levels but also doesn't include it in -Wextra
119119
check_and_add_compiler_flag(-Wimplicit-fallthrough=2 GCCImplicitFallthrough)
120120
if (WIN32)

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,7 @@ ACL_CHECK_ADD_COMPILE_FLAGS([-Wstrict-prototypes])
14101410
ACL_CHECK_ADD_COMPILE_FLAGS([-Wold-style-definition])
14111411
ACL_CHECK_ADD_COMPILE_FLAGS([-Wconversion -Wno-sign-conversion])
14121412
ACL_CHECK_ADD_COMPILE_FLAGS([-Wall])
1413-
ACL_CHECK_ADD_COMPILE_FLAGS([-Wextra -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter])
1413+
ACL_CHECK_ADD_COMPILE_FLAGS([-Wextra -Wno-sign-compare -Wno-unused-parameter])
14141414
# clang doesn't have the different levels but also doesn't include it in -Wextra
14151415
ACL_CHECK_ADD_COMPILE_FLAGS([-Wimplicit-fallthrough=2])
14161416
if test "${WIN32}" = "yes"; then

src/openvpn/event.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,13 @@ we_wait(struct event_set *es, const struct timeval *tv, struct event_set_return
410410
}
411411
#endif
412412

413+
/* WSA_WAIT_EVENT_0 == 0 but the API documentation is written in a way
414+
that doesn't guarantee that. So we make useless checks. */
415+
#if defined(__GNUC__)
416+
#pragma GCC diagnostic push
417+
#pragma GCC diagnostic ignored "-Wtype-limits"
418+
#endif
419+
413420
/*
414421
* First poll our event list with 0 timeout
415422
*/
@@ -474,6 +481,9 @@ we_wait(struct event_set *es, const struct timeval *tv, struct event_set_return
474481
return -1;
475482
}
476483
}
484+
#if defined(__GNUC__)
485+
#pragma GCC diagnostic pop
486+
#endif
477487
}
478488

479489
static struct event_set *

src/openvpn/socket.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,8 @@ create_socket_tcp(struct addrinfo *addrinfo)
577577
ASSERT(addrinfo);
578578
ASSERT(addrinfo->ai_socktype == SOCK_STREAM);
579579

580-
if ((sd = socket(addrinfo->ai_family, addrinfo->ai_socktype, addrinfo->ai_protocol)) < 0)
580+
if ((sd = socket(addrinfo->ai_family, addrinfo->ai_socktype, addrinfo->ai_protocol))
581+
== SOCKET_UNDEFINED)
581582
{
582583
msg(M_ERR, "Cannot create TCP socket");
583584
}
@@ -608,7 +609,8 @@ create_socket_udp(struct addrinfo *addrinfo, const unsigned int flags)
608609
ASSERT(addrinfo);
609610
ASSERT(addrinfo->ai_socktype == SOCK_DGRAM);
610611

611-
if ((sd = socket(addrinfo->ai_family, addrinfo->ai_socktype, addrinfo->ai_protocol)) < 0)
612+
if ((sd = socket(addrinfo->ai_family, addrinfo->ai_socktype, addrinfo->ai_protocol))
613+
== SOCKET_UNDEFINED)
612614
{
613615
msg(M_ERR, "UDP: Cannot create UDP/UDP6 socket");
614616
}

0 commit comments

Comments
 (0)