From: "cron2 (Code Review)" Date: Sun, 9 Nov 2025 11:11:20 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <710fb66e693512303995c547ec13f18228c0f2d6-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="W6Jg/jJLB4Q="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: dco_freebsd.c: fix integer warnings List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: flichtenheld , plaisthos , openvpn-devel --W6Jg/jJLB4Q= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/13= 61?usp=3Demail ) Change subject: dco_freebsd.c: fix integer warnings ...................................................................... dco_freebsd.c: fix integer warnings Fix all nvlist_get_number() related warnings by explicitly casting - these are all messages coming from DCO, which we trust in this (nothing will crash if a number is truncated, just "things will not work correctly"). Remove #pragmas. Change-Id: Ief19ba87b0832baa6530ea8bf039d85115434e3e Signed-off-by: Gert Doering Acked-by: Frank Lichtenheld Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1361 Message-Id: <20251107174810.31851-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34= 256.html Signed-off-by: Gert Doering --- M src/openvpn/dco_freebsd.c 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/openvpn/dco_freebsd.c b/src/openvpn/dco_freebsd.c index 21f0ac0..f2a89ac 100644 --- a/src/openvpn/dco_freebsd.c +++ b/src/openvpn/dco_freebsd.c @@ -72,11 +72,6 @@ return (nvl); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - static bool nvlist_to_sockaddr(const nvlist_t *nvl, struct sockaddr_storage *ss) { @@ -93,7 +88,7 @@ return (false); } - ss->ss_family =3D nvlist_get_number(nvl, "af"); + ss->ss_family =3D (unsigned char)nvlist_get_number(nvl, "af"); switch (ss->ss_family) { @@ -107,7 +102,7 @@ data =3D nvlist_get_binary(nvl, "address", &len); 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"); + in->sin_port =3D (in_port_t)nvlist_get_number(nvl, "port"); break; } @@ -121,11 +116,11 @@ data =3D nvlist_get_binary(nvl, "address", &len); 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"); + in6->sin6_port =3D (in_port_t)nvlist_get_number(nvl, "port"); if (nvlist_exists_number(nvl, "scopeid")) { - in6->sin6_scope_id =3D nvlist_get_number(nvl, "scopeid"); + in6->sin6_scope_id =3D (uint32_t)nvlist_get_number(nvl, "s= copeid"); } break; } @@ -614,9 +609,12 @@ return -EINVAL; } - dco->dco_message_peer_id =3D nvlist_get_number(nvl, "peerid"); + /* dco_message_peer_id is signed int, because other parts of the + * code treat "-1" as "this is a message not specific to one peer" + */ + dco->dco_message_peer_id =3D (int)nvlist_get_number(nvl, "peerid"); - type =3D nvlist_get_number(nvl, "notification"); + type =3D (enum ovpn_notif_type)nvlist_get_number(nvl, "notification"); switch (type) { @@ -625,7 +623,7 @@ if (nvlist_exists_number(nvl, "del_reason")) { - uint32_t reason =3D nvlist_get_number(nvl, "del_reason"); + uint32_t reason =3D (uint32_t)nvlist_get_number(nvl, "del_= reason"); if (reason =3D=3D OVPN_DEL_REASON_TIMEOUT) { dco->dco_del_peer_reason =3D OVPN_DEL_PEER_REASON_EXPI= RED; @@ -869,7 +867,7 @@ for (size_t i =3D 0; i < npeers; i++) { const nvlist_t *peer =3D nvpeers[i]; - uint32_t peerid =3D nvlist_get_number(peer, "peerid"); + uint32_t peerid =3D (uint32_t)nvlist_get_number(peer, "peerid"); const nvlist_t *bytes =3D nvlist_get_nvlist(peer, "bytes"); /* we can end here in p2mp mode, or in p2p mode via @@ -890,10 +888,6 @@ return 0; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - /* get stats for a single peer * we can get here for "the peer stats" in p2p client mode, or by * being queried for a particular peer in p2mp mode, for --inactive -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1361?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: merged Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ief19ba87b0832baa6530ea8bf039d85115434e3e Gerrit-Change-Number: 1361 Gerrit-PatchSet: 2 Gerrit-Owner: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel --W6Jg/jJLB4Q= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 sub= mitted this change.

View Change

dco_freebsd.c: fix integer warnings

Fix a= ll nvlist_get_number() related warnings by explicitly casting - these
ar= e all messages coming from DCO, which we trust in this (nothing will
cra= sh if a number is truncated, just "things will not work correctly"= ;).

Remove #pragmas.

Change-Id: Ief19ba87b0832baa6530ea8bf039= d85115434e3e
Signed-off-by: Gert Doering <gert@...1296...>
Acke= d-by: Frank Lichtenheld <frank@...2641...>
Gerrit URL: https://ger= rit.openvpn.net/c/openvpn/+/1361
Message-Id: <20251107174810.31851-1-= gert@...1296...>
URL: https://www.mail-archive.com/openvpn-devel@...1514...= s.sourceforge.net/msg34256.html
Signed-off-by: Gert Doering <gert@...493...= 1296...>
---
M src/openvpn/dco_freebsd.c
1 file changed, 11 ins= ertions(+), 17 deletions(-)

diff --git a/src/openvpn/dco_freebsd.c b/src/openvpn/dco_freebsd.c
index 21f0ac0..f2a89ac 100644
--- a/src/openvpn/= dco_freebsd.c
+++ b/src/openvpn/dco_freebsd.c
@@ -72,11 +72,6 @@
return (nvl);
}=

-#if= defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion&= quot;
-#endif-
static bool
nvlist_to_sockaddr(const nvlist_t *nvl, struct sockaddr_sto= rage *ss)
{
@@ -93,7 +88,7 @@
return (false);

}

- ss->ss_family =3D nv= list_get_number(nvl, "af");
+ ss->ss_family =3D (unsigned char)nvlist_get_number= (nvl, "af");

switch (ss-&g= t;ss_family)
{
@@ -107,7 +102,7 @@

data =3D nvlist_get_binary(nvl, "address&quo= t;, &len);
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&quo= t;);
+ in-= >sin_port =3D (in_port_t)nvlist_get_number(nvl, "port");
break;
}
=
@@ -121,11 +116,11 @@
data = =3D nvlist_get_binary(nvl, "address", &len);
= 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");
+ in6->sin6_port =3D (in_= port_t)nvlist_get_number(nvl, "port");
if (nvlist_exists_number(nvl, "scopeid"))
{
- in6->sin6_scope_id =3D nvlist_get_number(nvl, &qu= ot;scopeid");
+ = in6->sin6_scope_id =3D (uint32_t)nvlist_get_number(nvl, &= quot;scopeid");
}
= break;
}
@@ -614,9 +609,12 @= @
return -EINVAL;
}
- dco->d= co_message_peer_id =3D nvlist_get_number(nvl, "peerid");+ /* dco_message_peer_id i= s signed int, because other parts of the
+ * code treat "-1" as "this is a me= ssage not specific to one peer"
+ */
+ dco->dco_message_peer_id =3D (int)nvlist_get_number(nvl, "= peerid");

- type =3D nvlist_get_number(nvl, "notification");
+ type =3D (enum ov= pn_notif_type)nvlist_get_number(nvl, "notification");
<= span>

switch (type)
{
= @@ -625,7 +623,7 @@

if= (nvlist_exists_number(nvl, "del_reason"))
= {
- = uint32_t reason =3D nvlist_get_number(nvl, "del_reason");
+ uint32_t= reason =3D (uint32_t)nvlist_get_number(nvl, "del_reason");
if (reason =3D=3D OVPN_DEL_REASON_TIMEOUT)
{
dco->= ;dco_del_peer_reason =3D OVPN_DEL_PEER_REASON_EXPIRED;
@@ -= 869,7 +867,7 @@
for (size_t i =3D 0; i < npeers; i+= +)
{
const nvlist_t *peer =3D= nvpeers[i];
- u= int32_t peerid =3D nvlist_get_number(peer, "peerid");
<= span style=3D"color: hsl(120, 100%, 40%);">+ uint32_t peerid =3D (ui= nt32_t)nvlist_get_number(peer, "peerid");

= const nvlist_t *bytes =3D nvlist_get_nvlist(peer, "bytes");


/* we can end here in p2mp mode, or= in p2p mode via
@@ -890,10 +888,6 @@
= return 0;
}

-#if defined(__GNUC__) || defined(__clang__)=
-#pragma GCC diagnostic pop
-#endif
-
/* get stats for a s= ingle peer
* we can get here for "the peer stats&quo= t; in p2p client mode, or by
* being queried for a partic= ular peer in p2mp mode, for --inactive

= To view, visit change 1361. To unsubscribe, or for help writing mail filters, v= isit settings.

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ief19ba87b0832baa6530ea8bf03= 9d85115434e3e
Gerrit-Change-Number: 1361
Gerrit-PatchSet: 2
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>
= --W6Jg/jJLB4Q=--