From: "flichtenheld (Code Review)" Date: Tue, 30 Sep 2025 11:03:27 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="4Iah1Q4T7jA="; 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: plaisthos Cc: openvpn-devel --4Iah1Q4T7jA= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: plaisthos. Hello plaisthos, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1241?usp=3Demail to review the following change. 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 --- M src/openvpn/dhcp.c 1 file changed, 2 insertions(+), 11 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/41/1241/1 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)); 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: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ie0c0fbf4f7f8b379d46b6755c4eff209acc20fef Gerrit-Change-Number: 1241 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --4Iah1Q4T7jA= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: plaisthos.

flichtenheld would like plaisthos to review this change.

V= iew Change

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 <frank@...2641...>
---
M s= rc/openvpn/dhcp.c
1 file changed, 2 insertions(+), 11 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/=
changes/41/1241/1
diff --git a/src/openvpn/dhcp.c b/src/openvpn/dhc=
p.c
index 38e8d40..850a4b6 100644
--- a/src= /openvpn/dhcp.c
+++ b/src/openvpn/dhcp.c
@@= -72,11 +72,6 @@
return -1;
}<= br>
-#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 overwrite */
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, mo= vlen); /* 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(stru= ct dhcp));
+ -= (int)(sizeof(struct openvpn_iphdr) + sizeof(struct openvpn_udphdr) + sizeo= f(struct dhcp));

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 diagnost= ic pop
-#endif

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

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie0c0fbf4f7f8b379d46b6755c4e= ff209acc20fef
Gerrit-Change-Number: 1241
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
= --4Iah1Q4T7jA=--