From: Gert Doering Date: Sun, 7 Sep 2025 21:12:46 +0000 (+0200) Subject: replace assert() calls with ASSERT() X-Git-Tag: v2.6.15~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2c57936e8fcfef65e95328b9503eeffde5c6e26a;p=thirdparty%2Fopenvpn.git replace assert() calls with ASSERT() OpenVPN's ASSERT() macro will do a bit more than the standard-libc assert() call, namely print out which function and what expression failed, before calling _exit(1). Also, it can not be accidentially compiled-away (-DNDEBUG). Use of ASSERT() is generally only advised in cases of "this must not happen, but if it does, it's a programming or state corruption error that we must know about". Use of assert() is lacking the extra debug info, and as such, not advised at all. Change-Id: I6480d6f741c2368a0d951004b91167d5943f8f9d Signed-off-by: Gert Doering Acked-by: mandree Message-Id: <20250907211252.23924-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg32824.html Signed-off-by: Gert Doering (cherry picked from commit 88f8edbf7545dc7913d031ea12c4bae5250bb766) --- diff --git a/src/openvpn/dco_freebsd.c b/src/openvpn/dco_freebsd.c index 25532d42b..13a08319a 100644 --- a/src/openvpn/dco_freebsd.c +++ b/src/openvpn/dco_freebsd.c @@ -100,7 +100,7 @@ nvlist_to_sockaddr(const nvlist_t *nvl, struct sockaddr_storage *ss) in->sin_len = sizeof(*in); data = nvlist_get_binary(nvl, "address", &len); - assert(len == sizeof(in->sin_addr)); + ASSERT(len == sizeof(in->sin_addr)); memcpy(&in->sin_addr, data, sizeof(in->sin_addr)); in->sin_port = nvlist_get_number(nvl, "port"); break; @@ -114,7 +114,7 @@ nvlist_to_sockaddr(const nvlist_t *nvl, struct sockaddr_storage *ss) in6->sin6_len = sizeof(*in6); data = nvlist_get_binary(nvl, "address", &len); - assert(len == sizeof(in6->sin6_addr)); + ASSERT(len == sizeof(in6->sin6_addr)); memcpy(&in6->sin6_addr, data, sizeof(in6->sin6_addr)); in6->sin6_port = nvlist_get_number(nvl, "port"); break; diff --git a/src/openvpn/init.c b/src/openvpn/init.c index 103aa3c18..1476737ef 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -330,7 +330,7 @@ management_callback_send_cc_message(void *arg, static unsigned int management_callback_remote_entry_count(void *arg) { - assert(arg); + ASSERT(arg); struct context *c = (struct context *) arg; struct connection_list *l = c->options.connection_list; @@ -340,8 +340,8 @@ management_callback_remote_entry_count(void *arg) static bool management_callback_remote_entry_get(void *arg, unsigned int index, char **remote) { - assert(arg); - assert(remote); + ASSERT(arg); + ASSERT(remote); struct context *c = (struct context *) arg; struct connection_list *l = c->options.connection_list;