From: "cron2 (Code Review)" Date: Sun, 7 Sep 2025 10:22:07 +0000 References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <337d8f32cca468935416388ead94cc75243352ba-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="yee/f2YbEUM="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: replace assert() calls with ASSERT() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --yee/f2YbEUM= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, plaisthos. Hello plaisthos, flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1171?usp=3Demail to review the following change. Change subject: replace assert() calls with ASSERT() ...................................................................... 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() 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 --- M src/openvpn/dco_freebsd.c M src/openvpn/init.c M src/openvpn/options.c 3 files changed, 8 insertions(+), 8 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/71/1171/1 diff --git a/src/openvpn/dco_freebsd.c b/src/openvpn/dco_freebsd.c index 931f9f6..65303cd 100644 --- a/src/openvpn/dco_freebsd.c +++ b/src/openvpn/dco_freebsd.c @@ -100,7 +100,7 @@ in->sin_len =3D sizeof(*in); data =3D nvlist_get_binary(nvl, "address", &len); - assert(len =3D=3D sizeof(in->sin_addr)); + ASSERT(len =3D=3D sizeof(in->sin_addr)); memcpy(&in->sin_addr, data, sizeof(in->sin_addr)); in->sin_port =3D nvlist_get_number(nvl, "port"); break; @@ -114,7 +114,7 @@ in6->sin6_len =3D sizeof(*in6); data =3D nvlist_get_binary(nvl, "address", &len); - assert(len =3D=3D sizeof(in6->sin6_addr)); + ASSERT(len =3D=3D sizeof(in6->sin6_addr)); memcpy(&in6->sin6_addr, data, sizeof(in6->sin6_addr)); in6->sin6_port =3D nvlist_get_number(nvl, "port"); diff --git a/src/openvpn/init.c b/src/openvpn/init.c index 39ea8e4..2821cd4 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -319,7 +319,7 @@ static unsigned int management_callback_remote_entry_count(void *arg) { - assert(arg); + ASSERT(arg); struct context *c =3D (struct context *)arg; struct connection_list *l =3D c->options.connection_list; @@ -329,8 +329,8 @@ 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 =3D (struct context *)arg; struct connection_list *l =3D c->options.connection_list; diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 0616a17..6858a69 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -3486,9 +3486,9 @@ { /* Copy --dhcp-options to tuntap_options */ struct dhcp_options *dhcp =3D &dns->from_dhcp; - assert(sizeof(dhcp->dns) =3D=3D sizeof(tt->dns)); - assert(sizeof(dhcp->dns6) =3D=3D sizeof(tt->dns6)); - assert(sizeof(dhcp->domain_search_list) =3D=3D sizeof(tt->domain_s= earch_list)); + ASSERT(sizeof(dhcp->dns) =3D=3D sizeof(tt->dns)); + ASSERT(sizeof(dhcp->dns6) =3D=3D sizeof(tt->dns6)); + ASSERT(sizeof(dhcp->domain_search_list) =3D=3D sizeof(tt->domain_s= earch_list)); tt->domain =3D dhcp->domain; tt->dns_len =3D dhcp->dns_len; -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1171?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I6480d6f741c2368a0d951004b91167d5943f8f9d Gerrit-Change-Number: 1171 Gerrit-PatchSet: 1 Gerrit-Owner: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-MessageType: newchange --yee/f2YbEUM= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, plaisthos.

cron2 would like plaisthos and flichtenheld to review t= his change.

V= iew Change

replace assert() calls with ASSERT()

OpenVPN's AS= SERT() macro will do a bit more than the standard-libc
assert() call, na= mely print out which function and what expression
failed, before calling= _exit(1). Also, it can not be accidentially
compiled-away (-DNDEBUG).<= br>
Use of ASSERT() generally only advised in cases of "this must n= ot happen,
but if it does, it's a programming or state corruption er= ror that we
must know about". Use of assert() is lacking the extra= debug info, and as
such, not advised at all.

Change-Id: I6480d6f= 741c2368a0d951004b91167d5943f8f9d
Signed-off-by: Gert Doering <gert@...220...= ..1296...>
---
M src/openvpn/dco_freebsd.c
M src/openvpn/init.c=
M src/openvpn/options.c
3 files changed, 8 insertions(+), 8 deletion= s(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes=
/71/1171/1
diff --git a/src/openvpn/dco_freebsd.c b/src/openvpn/dco=
_freebsd.c
index 931f9f6..65303cd 100644
--= - a/src/openvpn/dco_freebsd.c
+++ b/src/openvpn/dco_freebsd= .c
@@ -100,7 +100,7 @@

= in->sin_len =3D sizeof(*in);
dat= a =3D nvlist_get_binary(nvl, "address", &len);
- assert(len =3D=3D sizeof= (in->sin_addr));
+= ASSERT(len =3D=3D sizeof(in->sin_addr));
= memcpy(&in->sin_addr, data, sizeof(in->sin_addr));

in->sin_port =3D nvlist_get_number(nvl, "p= ort");
break;
@@ -114,7 += 114,7 @@

in6->sin6_len = =3D sizeof(*in6);
data =3D nvlist_get_binary(n= vl, "address", &len);
- assert(len =3D=3D sizeof(in6->sin6_addr));
+ ASSERT(len = =3D=3D sizeof(in6->sin6_addr));
memcpy(&= ;in6->sin6_addr, data, sizeof(in6->sin6_addr));
= in6->sin6_port =3D nvlist_get_number(nvl, "port");

diff --git a/src/openvpn/init.c b/src/openvp= n/init.c
index 39ea8e4..2821cd4 100644
--- = a/src/openvpn/init.c
+++ b/src/openvpn/init.c
@@ -319,7 +319,7 @@

static unsigned int
management_callback_remote_entry_count(void *arg)

{
- assert(arg);+ ASSERT(arg);
struct context *c =3D (struct context *)arg;

= struct connection_list *l =3D c->options.connection_list;

@@ -329,8 +329,8 @@
static bool=
management_callback_remote_entry_get(void *arg, unsigned int ind= ex, char **remote)
{
- assert(arg);
- assert(remote);
+ ASSERT(arg);
+ ASSERT(remote);

struct c= ontext *c =3D (struct context *)arg;
struct connection= _list *l =3D c->options.connection_list;
diff --git a/sr= c/openvpn/options.c b/src/openvpn/options.c
index 0616a17..= 6858a69 100644
--- a/src/openvpn/options.c
= +++ b/src/openvpn/options.c
@@ -3486,9 +3486,9 @@ {
/* Copy --dhcp-options to tuntap_opt= ions */
struct dhcp_options *dhcp =3D &dns->= ;from_dhcp;
- as= sert(sizeof(dhcp->dns) =3D=3D sizeof(tt->dns));
- assert(sizeof(dhcp->dns6) =3D=3D= sizeof(tt->dns6));
= - assert(sizeof(dhcp->domain_search_list) =3D=3D sizeof(tt->do= main_search_list));
+= ASSERT(sizeof(dhcp->dns) =3D=3D sizeof(tt->dns));
<= span style=3D"color: hsl(120, 100%, 40%);">+ ASSERT(sizeof(dhcp->= dns6) =3D=3D sizeof(tt->dns6));
+ ASSERT(sizeof(dhcp->domain_search_list) =3D=3D si= zeof(tt->domain_search_list));

= tt->domain =3D dhcp->domain;
tt->dns_le= n =3D dhcp->dns_len;

To view, visit = change 1= 171. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6480d6f741c2368a0d951004b91= 167d5943f8f9d
Gerrit-Change-Number: 1171
Gerrit-PatchSet: 1
Gerrit-Owner: cron2 <gert@...1296...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newchange
--yee/f2YbEUM=--