From: "cron2 (Code Review)" Date: Fri, 7 Nov 2025 17:23:06 +0000 References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <00d16a365209c21cfb10298636ed59be45af26b5-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="ofrxxIgZ59I="; 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: , To: plaisthos , flichtenheld Cc: openvpn-devel --ofrxxIgZ59I= 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/+/1361?usp=3Demail to review the following change. 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 --- M src/openvpn/dco_freebsd.c 1 file changed, 11 insertions(+), 17 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/61/1361/1 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: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ief19ba87b0832baa6530ea8bf039d85115434e3e Gerrit-Change-Number: 1361 Gerrit-PatchSet: 1 Gerrit-Owner: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld --ofrxxIgZ59I= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: flichtenheld, plaisthos.

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

V= iew Change

dco_freebsd.c: fix integer warnings

= Fix all nvlist_get_number() related warnings by explicitly casting - these<= br>are all messages coming from DCO, which we trust in this (nothing willcrash if a number is truncated, just "things will not work correctly= ").

Remove #pragmas.

Change-Id: Ief19ba87b0832baa6530ea8= bf039d85115434e3e
Signed-off-by: Gert Doering <gert@...1296...>---
M src/openvpn/dco_freebsd.c
1 file changed, 11 insertions(+), 17= deletions(-)

git pull ssh://gerrit.openvpn.net:=
29418/openvpn refs/changes/61/1361/1
diff --git a/src/openvpn/dco_f=
reebsd.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 @@
<= span> return (nvl);
}

-#if defined(__GNUC__) || defined(__c= lang__)
-#pragma GCC di= agnostic push
-#pragma = GCC diagnostic ignored "-Wconversion"
-#endif
-
static bool
nvlist_to_sockadd= r(const nvlist_t *nvl, struct sockaddr_storage *ss)
{

@@ -93,7 +88,7 @@
return (false);
}

- ss->ss_family =3D nvlist_get_number(nvl, "af&quo= t;);
+ ss->ss_f= amily =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_po= rt =3D nvlist_get_number(nvl, "port");
+ in->sin_port =3D (in_port_t)nvl= ist_get_number(nvl, "port");
break;<= /span>
}

@@ -121,11 +11= 6,11 @@
data =3D nvlist_get_binary(nvl, "= address", &len);
ASSERT(len =3D=3D si= zeof(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, &qu= ot;port");

if (nvlist_e= xists_number(nvl, "scopeid"))
{
- in6->si= n6_scope_id =3D nvlist_get_number(nvl, "scopeid");
+ in6->sin6_scope= _id =3D (uint32_t)nvlist_get_number(nvl, "scopeid");

}

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&qu= ot;
+ */+ dco->dco_message_peer= _id =3D (int)nvlist_get_number(nvl, "peerid");
<= /span>
- type =3D nvlist_ge= t_number(nvl, "notification");
+ type =3D (enum ovpn_notif_type)nvlist_get_number(n= vl, "notification");

switc= h (type)
{
@@ -625,7 +623,7 @@<= br>
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 (r= eason =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++)
{<= br> const nvlist_t *peer =3D nvpeers[i];
- uint32_t peerid =3D nvlist_get_num= ber(peer, "peerid");
+ uint32_t peerid =3D (uint32_t)nvlist_get_number(peer, &q= uot;peerid");
const nvlist_t *bytes =3D nvlis= t_get_nvlist(peer, "bytes");

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

-#if defi= ned(__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 --ina= ctive

To view, visit change 1361. To unsubs= cribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ief19ba87b0832baa6530ea8bf03= 9d85115434e3e
Gerrit-Change-Number: 1361
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...>
= --ofrxxIgZ59I=--