Change in openvpn[master]: dhcp: Fix conversion warnings
A message that is not in the archive (sent off-list or not yet received): gerrit.1759230199000.Ie0c0fbf4f7f8b379d46b6755c4eff209acc20fef@...2715...
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=email
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
---
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
src/openvpn/dhcp.c +2 -11
@@ -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 = len +2 ;/* len of data to overwrite */ uint8_t *src = dest + owlen;uint8_t *end = p + optlen; -const int movlen = end - src; +const intptr_t movlen = end - src;if (movlen >0 ) {memmove (dest, src, movlen);/* overwrite router option */
@@ -155,7 +150,7 @@struct dhcp_full *df = (struct dhcp_full *)BPTR (ipbuf);const int optlen =BLEN (ipbuf) - - (sizeof (struct openvpn_iphdr ) +sizeof (struct openvpn_udphdr ) +sizeof (struct dhcp )); + - (int )(sizeof (struct openvpn_iphdr ) +sizeof (struct openvpn_udphdr ) +sizeof (struct dhcp ));if (optlen >=0 && df->ip.protocol ==OPENVPN_IPPROTO_UDP && df->udp.source == htons(BOOTPS_PORT) && df->udp.dest == 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=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie0c0fbf4f7f8b379d46b6755c4eff209acc20fef
Gerrit-Change-Number: 1241
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Attention is currently required from: flichtenheld, plaisthos.
cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1241?usp=email )
Change subject: dhcp: Fix conversion warnings
......................................................................
Patch Set 3: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1241?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie0c0fbf4f7f8b379d46b6755c4eff209acc20fef
Gerrit-Change-Number: 1241
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Mon, 06 Oct 2025 21:01:13 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
PATCH v3 1/1 dhcp: Fix conversion warnings
In reply to a message not in the archiveFrom: Frank Lichtenheld <[email protected]...>
- Use correct type for pointer difference
- Make sure that small sizeof sum is treated as int
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1241
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1241
This mail reflects revision 3 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/dhcp.c +2 -11
@@ -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 = len +2 ;/* len of data to overwrite */ uint8_t *src = dest + owlen;uint8_t *end = p + optlen; -const int movlen = end - src; +const intptr_t movlen = end - src;if (movlen >0 ) {memmove (dest, src, movlen);/* overwrite router option */
@@ -155,7 +150,7 @@struct dhcp_full *df = (struct dhcp_full *)BPTR (ipbuf);const int optlen =BLEN (ipbuf) - - (sizeof (struct openvpn_iphdr ) +sizeof (struct openvpn_udphdr ) +sizeof (struct dhcp )); + - (int )(sizeof (struct openvpn_iphdr ) +sizeof (struct openvpn_udphdr ) +sizeof (struct dhcp ));if (optlen >=0 && df->ip.protocol ==OPENVPN_IPPROTO_UDP && df->udp.source == htons(BOOTPS_PORT) && df->udp.dest == htons(BOOTPC_PORT)
@@ -190,7 +185,3 @@ }return 0 ; } - -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif
[Openvpn-devel] [PATCH applied] Re: dhcp: Fix conversion warnings
One learns something new about C every day :-) - had to look up what an "intptr_t" is ("it's an integer type big enough to hold any pointer type"), so that's the correct thing for pointer differences as well (even though it's not really relevant *here*, as we're not talking about ">4 Gbyte difference, in a 32/64 bit addressing model").
Anyway. Patch makes sense. BBs are happy. Not tested beyond a build test on ubuntu/mingw.
Your patch has been applied to the master branch.
commit d446715c537764076ea8d61233bf37d3bafa7624
Author: Frank Lichtenheld Date: Mon Oct 6 23:01:21 2025 +0200
dhcp: Fix conversion warnings
Signed-off-by: Frank Lichtenheld <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1241
Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59243110/
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#4) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1241?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by cron2
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
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1241
Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59243110/
---
M src/openvpn/dhcp.c
1 file changed, 2 insertions(+), 11 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/41/1241/4
src/openvpn/dhcp.c +2 -11
@@ -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 = len +2 ;/* len of data to overwrite */ uint8_t *src = dest + owlen;uint8_t *end = p + optlen; -const int movlen = end - src; +const intptr_t movlen = end - src;if (movlen >0 ) {memmove (dest, src, movlen);/* overwrite router option */
@@ -155,7 +150,7 @@struct dhcp_full *df = (struct dhcp_full *)BPTR (ipbuf);const int optlen =BLEN (ipbuf) - - (sizeof (struct openvpn_iphdr ) +sizeof (struct openvpn_udphdr ) +sizeof (struct dhcp )); + - (int )(sizeof (struct openvpn_iphdr ) +sizeof (struct openvpn_udphdr ) +sizeof (struct dhcp ));if (optlen >=0 && df->ip.protocol ==OPENVPN_IPPROTO_UDP && df->udp.source == htons(BOOTPS_PORT) && df->udp.dest == 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=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie0c0fbf4f7f8b379d46b6755c4eff209acc20fef
Gerrit-Change-Number: 1241
Gerrit-PatchSet: 4
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1241?usp=email )
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
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1241
Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59243110/
---
M src/openvpn/dhcp.c
1 file changed, 2 insertions(+), 11 deletions(-)
src/openvpn/dhcp.c +2 -11
@@ -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 = len +2 ;/* len of data to overwrite */ uint8_t *src = dest + owlen;uint8_t *end = p + optlen; -const int movlen = end - src; +const intptr_t movlen = end - src;if (movlen >0 ) {memmove (dest, src, movlen);/* overwrite router option */
@@ -155,7 +150,7 @@struct dhcp_full *df = (struct dhcp_full *)BPTR (ipbuf);const int optlen =BLEN (ipbuf) - - (sizeof (struct openvpn_iphdr ) +sizeof (struct openvpn_udphdr ) +sizeof (struct dhcp )); + - (int )(sizeof (struct openvpn_iphdr ) +sizeof (struct openvpn_udphdr ) +sizeof (struct dhcp ));if (optlen >=0 && df->ip.protocol ==OPENVPN_IPPROTO_UDP && df->udp.source == htons(BOOTPS_PORT) && df->udp.dest == 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=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie0c0fbf4f7f8b379d46b6755c4eff209acc20fef
Gerrit-Change-Number: 1241
Gerrit-PatchSet: 4
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>