From: "cron2 (Code Review)" Date: Mon, 8 Sep 2025 10:38:07 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., matthias.andree@...68..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <9312d7f2a28aa7aea41383c44af8eafbc2c311d5-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="h/KADhevuew="; 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: , Cc: mandree , plaisthos , flichtenheld , openvpn-devel --h/KADhevuew= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/11= 71?usp=3Demail ) 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() 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@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg32= 824.html 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(-) 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; --=20 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: 2 Gerrit-Owner: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: mandree Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: merged --h/KADhevuew= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 submitted this change.

View Change

replace assert() calls with ASSERT()

O= penVPN's ASSERT() macro will do a bit more than the standard-libc
as= sert() call, namely print out which function and what expression
failed,= before calling _exit(1). Also, it can not be accidentially
compiled-aw= ay (-DNDEBUG).

Use of ASSERT() is generally only advised in cases of= "this must not
happen, but if it does, it's a programming or s= tate corruption error
that we must know about". Use of assert() is= lacking the extra debug
info, and as such, not advised at all.

C= hange-Id: I6480d6f741c2368a0d951004b91167d5943f8f9d
Signed-off-by: Gert = Doering <gert@...1296...>
Acked-by: mandree <matthias.andree@...1186...= .68...>
Message-Id: <20250907211252.23924-1-gert@...1296...>URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg3= 2824.html
Signed-off-by: Gert Doering <gert@...1296...>
---
= M src/openvpn/dco_freebsd.c
M src/openvpn/init.c
M src/openvpn/option= s.c
3 files changed, 8 insertions(+), 8 deletions(-)

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-&g= t;sin_len =3D sizeof(*in);
data =3D nvlist_get= _binary(nvl, "address", &len);
- assert(len =3D=3D sizeof(in->sin_addr= ));
+ ASSE= RT(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 @@<= br>
in6->sin6_len =3D sizeof(*in6);<= /span>
data =3D nvlist_get_binary(nvl, "address&= quot;, &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->si= n6_port =3D nvlist_get_number(nvl, "port");

diff --git a/src/openvpn/init.c b/src/openvpn/init.cindex 39ea8e4..2821cd4 100644
--- a/src/openvpn/init= .c
+++ b/src/openvpn/init.c
@@ -319,7 +319,= 7 @@
static unsigned int
management_callb= ack_remote_entry_count(void *arg)
{
- assert(arg);
+ ASSERT(arg);
struct c= ontext *c =3D (struct context *)arg;
struct connection= _list *l =3D c->options.connection_list;

@@ -329,8 +329,8 @@
static bool
manage= ment_callback_remote_entry_get(void *arg, unsigned int index, char **remote= )
{
- = assert(arg);
- as= sert(remote);
+ AS= SERT(arg);
+ ASSER= T(remote);

struct context *c =3D (st= ruct context *)arg;
struct connection_list *l =3D c-&g= t;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->dn= s6));
- assert(s= izeof(dhcp->domain_search_list) =3D=3D sizeof(tt->domain_search_list)= );
+ ASSERT(si= zeof(dhcp->dns) =3D=3D sizeof(tt->dns));
+ ASSERT(sizeof(dhcp->dns6) =3D=3D size= of(tt->dns6));
+ = ASSERT(sizeof(dhcp->domain_search_list) =3D=3D sizeof(tt->domai= n_search_list));

tt->domain = =3D dhcp->domain;
tt->dns_len =3D dhcp->d= ns_len;

To view, visit change 1171. To unsu= bscribe, 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: 2
Gerrit-Owner: cron2 <gert@...1296...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: mandree <matthias.andree@...220...= ..68...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: merged
--h/KADhevuew=--