Skip to content

Commit 88f8edb

Browse files
committed
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 <[email protected]> Acked-by: mandree <[email protected]> Message-Id: <[email protected]> URL: https://www.mail-archive.com/[email protected]/msg32824.html Signed-off-by: Gert Doering <[email protected]>
1 parent 1e7b9a0 commit 88f8edb

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/openvpn/dco_freebsd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ nvlist_to_sockaddr(const nvlist_t *nvl, struct sockaddr_storage *ss)
100100

101101
in->sin_len = sizeof(*in);
102102
data = nvlist_get_binary(nvl, "address", &len);
103-
assert(len == sizeof(in->sin_addr));
103+
ASSERT(len == sizeof(in->sin_addr));
104104
memcpy(&in->sin_addr, data, sizeof(in->sin_addr));
105105
in->sin_port = nvlist_get_number(nvl, "port");
106106
break;
@@ -114,7 +114,7 @@ nvlist_to_sockaddr(const nvlist_t *nvl, struct sockaddr_storage *ss)
114114

115115
in6->sin6_len = sizeof(*in6);
116116
data = nvlist_get_binary(nvl, "address", &len);
117-
assert(len == sizeof(in6->sin6_addr));
117+
ASSERT(len == sizeof(in6->sin6_addr));
118118
memcpy(&in6->sin6_addr, data, sizeof(in6->sin6_addr));
119119
in6->sin6_port = nvlist_get_number(nvl, "port");
120120

src/openvpn/init.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ management_callback_send_cc_message(void *arg, const char *command, const char *
319319
static unsigned int
320320
management_callback_remote_entry_count(void *arg)
321321
{
322-
assert(arg);
322+
ASSERT(arg);
323323
struct context *c = (struct context *)arg;
324324
struct connection_list *l = c->options.connection_list;
325325

@@ -329,8 +329,8 @@ management_callback_remote_entry_count(void *arg)
329329
static bool
330330
management_callback_remote_entry_get(void *arg, unsigned int index, char **remote)
331331
{
332-
assert(arg);
333-
assert(remote);
332+
ASSERT(arg);
333+
ASSERT(remote);
334334

335335
struct context *c = (struct context *)arg;
336336
struct connection_list *l = c->options.connection_list;

src/openvpn/options.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3486,9 +3486,9 @@ tuntap_options_postprocess_dns(struct options *o)
34863486
{
34873487
/* Copy --dhcp-options to tuntap_options */
34883488
struct dhcp_options *dhcp = &dns->from_dhcp;
3489-
assert(sizeof(dhcp->dns) == sizeof(tt->dns));
3490-
assert(sizeof(dhcp->dns6) == sizeof(tt->dns6));
3491-
assert(sizeof(dhcp->domain_search_list) == sizeof(tt->domain_search_list));
3489+
ASSERT(sizeof(dhcp->dns) == sizeof(tt->dns));
3490+
ASSERT(sizeof(dhcp->dns6) == sizeof(tt->dns6));
3491+
ASSERT(sizeof(dhcp->domain_search_list) == sizeof(tt->domain_search_list));
34923492

34933493
tt->domain = dhcp->domain;
34943494
tt->dns_len = dhcp->dns_len;

0 commit comments

Comments
 (0)