From: "cron2 (Code Review)" Date: Tue, 7 Oct 2025 07:37:10 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="c8etaub/lOk="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: dhcp: Fix conversion warnings List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: plaisthos , openvpn-devel --c8etaub/lOk= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/12= 41?usp=3Demail ) Change subject: dhcp: Fix conversion warnings ...................................................................... dhcp: Fix conversion warnings - Use correct type for pointer difference - Make sure that small sizeof sum is treated as int Change-Id: Ie0c0fbf4f7f8b379d46b6755c4eff209acc20fef Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1241 Message-Id: <20251006210127.28679-1-gert@...1296...> URL: https://sourceforge.net/p/openvpn/mailman/message/59243110/ Signed-off-by: Gert Doering --- M src/openvpn/dhcp.c 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/openvpn/dhcp.c b/src/openvpn/dhcp.c index 38e8d40..850a4b6 100644 --- a/src/openvpn/dhcp.c +++ b/src/openvpn/dhcp.c @@ -72,11 +72,6 @@ return -1; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - static in_addr_t do_extract(struct dhcp *dhcp, int optlen) { @@ -115,7 +110,7 @@ const int owlen =3D len + 2; /* len of data to ove= rwrite */ uint8_t *src =3D dest + owlen; uint8_t *end =3D p + optlen; - const int movlen =3D end - src; + const intptr_t movlen =3D end - src; if (movlen > 0) { memmove(dest, src, movlen); /* overwrite= router option */ @@ -155,7 +150,7 @@ struct dhcp_full *df =3D (struct dhcp_full *)BPTR(ipbuf); const int optlen =3D BLEN(ipbuf) - - (sizeof(struct openvpn_iphdr) + sizeof(struct openvpn_udphdr) + = sizeof(struct dhcp)); + - (int)(sizeof(struct openvpn_iphdr) + sizeof(struct openvpn_udphd= r) + sizeof(struct dhcp)); =20 if (optlen >=3D 0 && df->ip.protocol =3D=3D OPENVPN_IPPROTO_UDP && df->udp.source =3D=3D htons(BOOTPS_PORT) && df->udp.dest =3D=3D= htons(BOOTPC_PORT) @@ -190,7 +185,3 @@ } return 0; } - -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1241?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: Ie0c0fbf4f7f8b379d46b6755c4eff209acc20fef Gerrit-Change-Number: 1241 Gerrit-PatchSet: 4 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel --c8etaub/lOk= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 sub= mitted this change.

View Change

dhcp: Fix conversion warnings

- Use corre= ct type for pointer difference
- Make sure that small sizeof sum is trea= ted as int

Change-Id: Ie0c0fbf4f7f8b379d46b6755c4eff209acc20fef
S= igned-off-by: Frank Lichtenheld <frank@...2641...>
Acked-by: Gert = Doering <gert@...1296...>
Gerrit URL: https://gerrit.openvpn.net/c= /openvpn/+/1241
Message-Id: <20251006210127.28679-1-gert@...1296...&g= t;
URL: https://sourceforge.net/p/openvpn/mailman/message/59243110/
S= igned-off-by: Gert Doering <gert@...1296...>
---
M src/openvpn/= dhcp.c
1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/src/openvpn/dhcp.c b/src/openvpn/dhcp.c
ind= ex 38e8d40..850a4b6 100644
--- a/src/openvpn/dhcp.c<= br>+++ b/src/openvpn/dhcp.c
@@ -72,11 +72,6 @@=
return -1;
}

-#if defined(__GNUC__) || defined(_= _clang__)
-#pragma GCC = diagnostic push
-#pragm= a GCC diagnostic ignored "-Wconversion"
-#endif
-
static in_addr_t
do_extract= (struct dhcp *dhcp, int optlen)
{
@@ -115,= 7 +110,7 @@
const int owlen =3D le= n + 2; /* len of data to overwrite */
= uint8_t *src =3D dest + owlen;
= uint8_t *end =3D p + optlen;
- const int movlen =3D end - src;
<= span style=3D"color: hsl(120, 100%, 40%);">+ const i= ntptr_t movlen =3D end - src;
if (= movlen > 0)
{
= memmove(dest, src, movlen); /* overwrite = router option */
@@ -155,7 +150,7 @@
s= truct dhcp_full *df =3D (struct dhcp_full *)BPTR(ipbuf);
= const int optlen =3D
BLEN(ipbuf)
- - (sizeof(struct openvpn_iph= dr) + sizeof(struct openvpn_udphdr) + sizeof(struct dhcp));
+ - (int)(sizeof(struct openv= pn_iphdr) + sizeof(struct openvpn_udphdr) + sizeof(struct dhcp));
if (optlen >=3D 0 && df->ip.pro= tocol =3D=3D OPENVPN_IPPROTO_UDP
&& df->= ;udp.source =3D=3D htons(BOOTPS_PORT) && df->udp.dest =3D=3D hto= ns(BOOTPC_PORT)
@@ -190,7 +185,3 @@
}<= /span>
return 0;
}
-
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif

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

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie0c0fbf4f7f8b379d46b6755c4e= ff209acc20fef
Gerrit-Change-Number: 1241
Gerrit-PatchSet: 4
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --c8etaub/lOk=--