From: "plaisthos (Code Review)" Date: Mon, 24 Mar 2025 13:18:29 +0000 References: Reply-To: arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <2f05c6780e43d1255945871f43ecea6ef299351f-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="D4jOVxh14bc="; 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: flichtenheld Cc: openvpn-devel --D4jOVxh14bc= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld. Hello flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/915?usp=3Demail to review the following change. 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 --- M src/openvpnserv/interactive.c 1 file changed, 4 insertions(+), 1 deletion(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/15/915/1 diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c index e64ac30..abc2cda 100644 --- a/src/openvpnserv/interactive.c +++ b/src/openvpnserv/interactive.c @@ -34,6 +34,7 @@ #include #include #include +#include #include @@ -1901,7 +1902,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: 1 Gerrit-Owner: plaisthos Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-Attention: flichtenheld Gerrit-MessageType: newchange --D4jOVxh14bc= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld.

plaisthos would like flichtenheld to review this change.

Vi= ew Change

Directly use _countof in array initialisation

This fix= es the build failures on MSVC cl compiler.

MSVC cl does not thinks o= f the expression of a const variable times
an integer to be compile time= static. C23 introduce the constexpr
(like in C++) statement for that bu= t we are only on C11 for now.

So directly use the _countof(msg->a= ddr) expression in the array
initialisation.

Change-Id: Ib579c153= 8eb5440bb7008bc866a5cb7d74844374
Signed-off-by: Arne Schwabe <arne@...1186...= .1227...>
---
M src/openvpnserv/interactive.c
1 file changed, 4= insertions(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:2=
9418/openvpn refs/changes/15/915/1
diff --git a/src/openvpnserv/int=
eractive.c b/src/openvpnserv/interactive.c
index e64ac30..a= bc2cda 100644
--- a/src/openvpnserv/interactive.c+++ b/src/openvpnserv/interactive.c
@@ -34,6 +34,7 @= @
#include <shellapi.h>
#include &l= t;mstcpip.h>
#include <inttypes.h>
+#include <assert.h>
#include <versionhelpers.h>

@@ -1901,7 +1902,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 b= y 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 = change 91= 5. 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: 1
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newchange
--D4jOVxh14bc=--