From: "cron2 (Code Review)" Date: Mon, 24 Mar 2025 13:54:00 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <5f5258e8299bea649821ef416f173d2e7d46a6d7-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="AGgpSYN1TJk="; charset=UTF-8 Subject: [Openvpn-devel] [XS] Change in openvpn[master]: Directly use _countof in array initialisation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --AGgpSYN1TJk= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#3) to the change originally created by= plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/915?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by flichtenheld Change subject: Directly use _countof in array initialisation ...................................................................... Directly use _countof in array initialisation This fixes the build failures on MSVC cl compiler. MSVC cl does not thinks of the expression of a const variable times an integer to be compile time static. C23 introduce the constexpr (like in C++) statement for that but we are only on C11 for now. So directly use the _countof(msg->addr) expression in the array initialisation. Change-Id: Ib579c1538eb5440bb7008bc866a5cb7d74844374 Signed-off-by: Arne Schwabe Acked-by: Frank Lichtenheld Message-Id: <20250324133759.13155-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31= 205.html Signed-off-by: Gert Doering --- M src/openvpnserv/interactive.c 1 file changed, 3 insertions(+), 1 deletion(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/15/915/3 diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c index e64ac30..c6963b3 100644 --- a/src/openvpnserv/interactive.c +++ b/src/openvpnserv/interactive.c @@ -1901,7 +1901,9 @@ if (msg->addr_len > 0) { /* prepare the comma separated address list */ - CHAR addrs[max_addrs * 64]; /* 64 is enough for one IPv4/6 address= */ + /* cannot use max_addrs here as that is not considered compile + * time constant by all compilers and constexpr is C23 */ + CHAR addrs[_countof(msg->addr) * 64]; /* 64 is enough for one IPv4= /6 address */ size_t offset =3D 0; for (int i =3D 0; i < addr_len; ++i) { -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/915?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: Ib579c1538eb5440bb7008bc866a5cb7d74844374 Gerrit-Change-Number: 915 Gerrit-PatchSet: 3 Gerrit-Owner: plaisthos Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-MessageType: newpatchset --AGgpSYN1TJk= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 uploaded patch set #3 to the change originally cr= eated by plaisthos.

View Change

The following approvals got outdated= and were removed: Code-Review+2 by flichtenheld

Directly use _countof in array initialisation=


This fixes the build failures on MSVC cl compiler.

MSVC cl d= oes not thinks of the expression of a const variable times
an integer to= be compile time static. C23 introduce the constexpr
(like in C++) state= ment for that but we are only on C11 for now.

So directly use the _c= ountof(msg->addr) expression in the array
initialisation.

Chan= ge-Id: Ib579c1538eb5440bb7008bc866a5cb7d74844374
Signed-off-by: Arne Sch= wabe <arne@...1227...>
Acked-by: Frank Lichtenheld <frank@...2375...= 41...>
Message-Id: <20250324133759.13155-1-gert@...1296...>
= URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31= 205.html
Signed-off-by: Gert Doering <gert@...1296...>
---
M= src/openvpnserv/interactive.c
1 file changed, 3 insertions(+), 1 deleti= on(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/change=
s/15/915/3
diff --git a/src/openvpnserv/interactive.c b/src/openvpn=
serv/interactive.c
index e64ac30..c6963b3 100644
= --- a/src/openvpnserv/interactive.c
+++ b/src/openvpn= serv/interactive.c
@@ -1901,7 +1901,9 @@
= if (msg->addr_len > 0)
{
= /* prepare the comma separated address list */
- CHAR addrs[max_addrs * 64]; /* 64 i= s enough for one IPv4/6 address */
+ /* cannot use max_addrs here as that is not consider= ed compile
+ = * time constant by all compilers and constexpr is C23 */
+ CHAR addrs[_countof(msg->ad= dr) * 64]; /* 64 is enough for one IPv4/6 address */
= size_t offset =3D 0;
for (int i =3D 0; i < a= ddr_len; ++i)
{

<= p>To view, visit change 915. To unsubscribe, or for help writing mail filters,= visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib579c1538eb5440bb7008bc866a= 5cb7d74844374
Gerrit-Change-Number: 915
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: newpatchset
--AGgpSYN1TJk=--