From: "cron2 (Code Review)" Date: Sat, 18 Oct 2025 18:03:45 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., marco@...2726..., 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="EThqabQlpJM="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: push_util: Fix conversion warnings List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld , plaisthos , mrbff Cc: openvpn-devel --EThqabQlpJM= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: cron2. cron2 has uploaded a new patch set (#2) to the change originally created by= flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1283?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+1 by cron2, Code-Review+2 by mrbff Change subject: push_util: Fix conversion warnings ...................................................................... push_util: Fix conversion warnings Mostly just use better types. Change-Id: I4113d14c6ce33818573b0ca5857a9ab39b35a8f4 Signed-off-by: Frank Lichtenheld Acked-by: mrbff Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1283 Message-Id: <20251018170237.21928-1-gert@...1296...> URL: https://sourceforge.net/p/openvpn/mailman/message/59248341/ Signed-off-by: Gert Doering --- M src/openvpn/push_util.c 1 file changed, 15 insertions(+), 24 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/83/1283/2 diff --git a/src/openvpn/push_util.c b/src/openvpn/push_util.c index 0eddcae..552679a 100644 --- a/src/openvpn/push_util.c +++ b/src/openvpn/push_util.c @@ -10,17 +10,12 @@ #include "ssl_util.h" #endif -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - int process_push_update(struct context *c, struct options *o, unsigned int per= mission_mask, unsigned int *option_types_found, struct buffer *buf, = bool msg_sender) { int ret =3D PUSH_MSG_ERROR; - const uint8_t ch =3D buf_read_u8(buf); + const int ch =3D buf_read_u8(buf); if (ch =3D=3D ',') { if (apply_push_options(c, o, buf, permission_mask, option_types_fo= und, c->c2.es, @@ -56,8 +51,8 @@ * Return index of last `,` or `0` if it didn't find any. * If there is a comma at index `0` it's an error anyway */ -static int -find_first_comma_of_next_bundle(const char *str, int ix) +static size_t +find_first_comma_of_next_bundle(const char *str, size_t ix) { while (ix > 0) { @@ -74,8 +69,8 @@ static struct buffer forge_msg(const char *src, const char *continuation, struct gc_arena *gc) { - int src_len =3D strlen(src); - int con_len =3D continuation ? strlen(continuation) : 0; + size_t src_len =3D strlen(src); + size_t con_len =3D continuation ? strlen(continuation) : 0; struct buffer buf =3D alloc_buf_gc(src_len + sizeof(push_update_cmd) += con_len + 2, gc); buf_printf(&buf, "%s,%s%s", push_update_cmd, src, continuation ? conti= nuation : ""); @@ -92,11 +87,11 @@ return ret; } -/* It split the messagge (if necessay) and fill msgs with the message chun= ks. +/* It split the messagge (if necessary) and fill msgs with the message chu= nks. * Return `false` on failure an `true` on success. */ static bool -message_splitter(const char *s, struct buffer *msgs, struct gc_arena *gc, = const int safe_cap) +message_splitter(const char *s, struct buffer *msgs, struct gc_arena *gc, = const size_t safe_cap) { if (!s || !*s) { @@ -104,7 +99,7 @@ } char *str =3D gc_strdup(s, gc); - int i =3D 0; + size_t i =3D 0; int im =3D 0; while (*str) @@ -112,7 +107,7 @@ /* + ',' - '/0' */ if (strlen(str) > safe_cap) { - int ci =3D find_first_comma_of_next_bundle(str, safe_cap); + size_t ci =3D find_first_comma_of_next_bundle(str, safe_cap); if (!ci) { /* if no commas were found go to fail, do not send any mes= sage */ @@ -254,7 +249,7 @@ * @return The number of clients to which the message was sent. Might retu= rn < 0 in case of error. */ static int -send_push_update(struct multi_context *m, const void *target, const char *= msg, const push_update_type type, const int push_bundle_size) +send_push_update(struct multi_context *m, const void *target, const char *= msg, const push_update_type type, const size_t push_bundle_size) { if (dco_enabled(&m->top.options)) { @@ -263,19 +258,19 @@ return 0; } - if (!msg || !*msg || !m - || (!target && type !=3D UPT_BROADCAST)) + if (!msg || !*msg || !m || (!target && type !=3D UPT_BROADCAST)) { return -EINVAL; } struct gc_arena gc =3D gc_new(); /* extra space for possible trailing ifconfig and push-continuation */ - const int extra =3D 84 + sizeof(push_update_cmd); + const size_t extra =3D 84 + sizeof(push_update_cmd); /* push_bundle_size is the maximum size of a message, so if the message * we want to send exceeds that size we have to split it into smaller = messages */ - const int safe_cap =3D push_bundle_size - extra; - int msgs_num =3D (strlen(msg) / safe_cap) + ((strlen(msg) % safe_cap) = !=3D 0); + ASSERT(push_bundle_size > extra); + const size_t safe_cap =3D push_bundle_size - extra; + size_t msgs_num =3D (strlen(msg) / safe_cap) + ((strlen(msg) % safe_ca= p) !=3D 0); struct buffer *msgs =3D gc_malloc((msgs_num + 1) * sizeof(struct buffe= r), true, &gc); msgs[msgs_num].data =3D NULL; @@ -374,7 +369,3 @@ RETURN_UPDATE_STATUS(n_sent); } #endif /* ifdef ENABLE_MANAGEMENT */ - -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1283?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newpatchset Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I4113d14c6ce33818573b0ca5857a9ab39b35a8f4 Gerrit-Change-Number: 1283 Gerrit-PatchSet: 2 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: mrbff Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: cron2 --EThqabQlpJM= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: cron2.

cron2 uploaded patch set #2 to the change originally cr= eated by flichtenheld.

View Change

The following approvals got outd= ated and were removed: Code-Review+1 by cron2, Code-Review+2 by mrbff

push_util: =
Fix conversion warnings

Mostly just use better types.

Change-= Id: I4113d14c6ce33818573b0ca5857a9ab39b35a8f4
Signed-off-by: Frank Licht= enheld <frank@...2641...>
Acked-by: mrbff <marco@...2726...>=
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1283
Message-Id: = <20251018170237.21928-1-gert@...1296...>
URL: https://sourceforge.= net/p/openvpn/mailman/message/59248341/
Signed-off-by: Gert Doering <= gert@...1296...>
---
M src/openvpn/push_util.c
1 file changed, = 15 insertions(+), 24 deletions(-)

git pull ssh:=
//gerrit.openvpn.net:29418/openvpn refs/changes/83/1283/2
diff --=
git a/src/openvpn/push_util.c b/src/openvpn/push_util.c
ind= ex 0eddcae..552679a 100644
--- a/src/openvpn/push_util.c
+++ b/src/openvpn/push_util.c
@@ -10,17 +10,1= 2 @@
#include "ssl_util.h"
#end= if

-#= if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversio= n"
-#endif<= br>-
int<= br> process_push_update(struct context *c, struct options *o, unsigne= d int permission_mask,
unsigned int *o= ption_types_found, struct buffer *buf, bool msg_sender)
{<= /span>
int ret =3D PUSH_MSG_ERROR;
- const uint8_t ch =3D buf_read_u8(buf);
+ const int ch =3D buf_= read_u8(buf);
if (ch =3D=3D ',')
{

if (apply_push_options(c, o, buf, permis= sion_mask, option_types_found, c->c2.es,
@@ -56,8 +51,8 = @@
* Return index of last `,` or `0` if it didn't fin= d any.
* If there is a comma at index `0` it's an err= or anyway
*/
-static int
-fi= nd_first_comma_of_next_bundle(const char *str, int ix)
+static size_t
+find_first_comma_of_next_bundle(const char *st= r, size_t ix)
{
while (ix > 0)
{
@@ -74,8 +69,8 @@
stat= ic struct buffer
forge_msg(const char *src, const char *co= ntinuation, struct gc_arena *gc)
{
- int src_len =3D strlen(src);
= - int con_len =3D continuation= ? strlen(continuation) : 0;
+ size_t src_len =3D strlen(src);
+ size_t con_len =3D continuation ? strlen(conti= nuation) : 0;
struct buffer buf =3D alloc_buf_gc(src_l= en + sizeof(push_update_cmd) + con_len + 2, gc);
buf_printf(&buf, "%s,%s%s", push_update_cmd, src= , continuation ? continuation : "");
@@ -92,11 +8= 7,11 @@
return ret;
}

-/* It split the mes= sagge (if necessay) and fill msgs with the message chunks.
+/* It split the messagge (if necessa= ry) and fill msgs with the message chunks.
* Return `fals= e` on failure an `true` on success.
*/
s= tatic bool
-message_spl= itter(const char *s, struct buffer *msgs, struct gc_arena *gc, const int sa= fe_cap)
+message_spli= tter(const char *s, struct buffer *msgs, struct gc_arena *gc, const size_t = safe_cap)
{
if (!s || !*s)
= {
@@ -104,7 +99,7 @@
}

char *str =3D gc_strdup(s, gc);- int i =3D 0;
+ size_t i =3D 0;

int im =3D 0;


while (*str)
@@ -112,7 +107,7 @@
/* + ','= ; - '/0' */
if (strlen(str) > safe_cap)=
{
- int ci =3D find_first_comma_of_next_bundle(str, safe_cap)= ;
+ size_t= ci =3D find_first_comma_of_next_bundle(str, safe_cap);
= if (!ci)
{
= /* if no commas were found go to fail, do not send any message */
@@ -254,7 +249,7 @@
* @return The number o= f clients to which the message was sent. Might return < 0 in case of err= or.
*/
static int
-send_push_update(struct multi_context *m, c= onst void *target, const char *msg, const push_update_type type, const int = push_bundle_size)
+se= nd_push_update(struct multi_context *m, const void *target, const char *msg= , const push_update_type type, const size_t push_bundle_size)
{

if (dco_enabled(&m->top.options))<= br> {
@@ -263,19 +258,19 @@
= return 0;
}

- if (!msg || !*msg || !m
- || (!target && type = !=3D UPT_BROADCAST))

= + if (!msg || !*msg || !m || (!target && type !=3D UPT_BROADCAST= ))
{
return -EINVAL; }

struct gc_arena gc = =3D gc_new();
/* extra space for possible trailing ifc= onfig and push-continuation */
- const int extra =3D 84 + sizeof(push_update_cmd);
+ const size_t extra =3D 84 + = sizeof(push_update_cmd);

/* push_bundle_size is the ma= ximum size of a message, so if the message
* we want = to send exceeds that size we have to split it into smaller messages */
- const int safe_cap =3D= push_bundle_size - extra;
- int msgs_num =3D (strlen(msg) / safe_cap) + ((strlen(msg) % safe_c= ap) !=3D 0);
+ ASS= ERT(push_bundle_size > extra);
+ const size_t safe_cap =3D push_bundle_size - extra;
+ size_t msgs_num =3D (= strlen(msg) / safe_cap) + ((strlen(msg) % safe_cap) !=3D 0);
struct buffer *msgs =3D gc_malloc((msgs_num + 1) * sizeof(struct buf= fer), true, &gc);


msgs[msgs_num]= .data =3D NULL;
@@ -374,7 +369,3 @@
RE= TURN_UPDATE_STATUS(n_sent);
}
#endif /* i= fdef ENABLE_MANAGEMENT */
-
-#if defined(__GNU= C__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif

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

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4113d14c6ce33818573b0ca5857= a9ab39b35a8f4
Gerrit-Change-Number: 1283
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: mrbff <marco@...2726...>= ;
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: cron2 <gert@...1296...>= ;
= --EThqabQlpJM=--