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 <gert@greenie.muc.de>
Acked-by: mandree <matthias.andree@gmx.de>
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 <gert@greenie.muc.de>
(cherry picked from commit 88f8edbf7545dc7913d031ea12c4bae5250bb766)
| ... | ... |
@@ -100,7 +100,7 @@ nvlist_to_sockaddr(const nvlist_t *nvl, struct sockaddr_storage *ss) |
| 100 | 100 |
|
| 101 | 101 |
in->sin_len = sizeof(*in); |
| 102 | 102 |
data = nvlist_get_binary(nvl, "address", &len); |
| 103 |
- assert(len == sizeof(in->sin_addr)); |
|
| 103 |
+ ASSERT(len == sizeof(in->sin_addr)); |
|
| 104 | 104 |
memcpy(&in->sin_addr, data, sizeof(in->sin_addr)); |
| 105 | 105 |
in->sin_port = nvlist_get_number(nvl, "port"); |
| 106 | 106 |
break; |
| ... | ... |
@@ -114,7 +114,7 @@ nvlist_to_sockaddr(const nvlist_t *nvl, struct sockaddr_storage *ss) |
| 114 | 114 |
|
| 115 | 115 |
in6->sin6_len = sizeof(*in6); |
| 116 | 116 |
data = nvlist_get_binary(nvl, "address", &len); |
| 117 |
- assert(len == sizeof(in6->sin6_addr)); |
|
| 117 |
+ ASSERT(len == sizeof(in6->sin6_addr)); |
|
| 118 | 118 |
memcpy(&in6->sin6_addr, data, sizeof(in6->sin6_addr)); |
| 119 | 119 |
in6->sin6_port = nvlist_get_number(nvl, "port"); |
| 120 | 120 |
break; |
| ... | ... |
@@ -330,7 +330,7 @@ management_callback_send_cc_message(void *arg, |
| 330 | 330 |
static unsigned int |
| 331 | 331 |
management_callback_remote_entry_count(void *arg) |
| 332 | 332 |
{
|
| 333 |
- assert(arg); |
|
| 333 |
+ ASSERT(arg); |
|
| 334 | 334 |
struct context *c = (struct context *) arg; |
| 335 | 335 |
struct connection_list *l = c->options.connection_list; |
| 336 | 336 |
|
| ... | ... |
@@ -340,8 +340,8 @@ management_callback_remote_entry_count(void *arg) |
| 340 | 340 |
static bool |
| 341 | 341 |
management_callback_remote_entry_get(void *arg, unsigned int index, char **remote) |
| 342 | 342 |
{
|
| 343 |
- assert(arg); |
|
| 344 |
- assert(remote); |
|
| 343 |
+ ASSERT(arg); |
|
| 344 |
+ ASSERT(remote); |
|
| 345 | 345 |
|
| 346 | 346 |
struct context *c = (struct context *) arg; |
| 347 | 347 |
struct connection_list *l = c->options.connection_list; |