From: "flichtenheld (Code Review)" Date: Thu, 11 Dec 2025 15:42:28 +0000 In-Reply-To: References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <18c0f9df46a07ddad0241b0cc2ffe92c2b2495df-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="HO5yd6nNVyg="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: mbuf: Fix conversion warnings in mbuf and related code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --HO5yd6nNVyg= 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 reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/1433?usp=3Demail to look at the new patch set (#3). Change subject: mbuf: Fix conversion warnings in mbuf and related code ...................................................................... mbuf: Fix conversion warnings in mbuf and related code Mostly these were actually hidden by casts, but fix them as well by using more fitting types. Change-Id: I1d4e0233cf1cb09725dbd2caa121acdbf62f0452 Signed-off-by: Frank Lichtenheld --- M src/openvpn/buffer.c M src/openvpn/mbuf.c 2 files changed, 6 insertions(+), 18 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/33/1433/3 diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c index 40baca6..dca44d6 100644 --- a/src/openvpn/buffer.c +++ b/src/openvpn/buffer.c @@ -43,7 +43,7 @@ unsigned long long res =3D (unsigned long long)m1 * (unsigned long long)m2 + (unsigned long l= ong)extra; if (unlikely(m1 > limit) || unlikely(m2 > limit) || unlikely(extra > l= imit) - || unlikely(res > (unsigned long long)limit)) + || unlikely(res > limit)) { msg(M_FATAL, "attempted allocation of excessively large array"); } @@ -53,7 +53,7 @@ void buf_size_error(const size_t size) { - msg(M_FATAL, "fatal buffer size error, size=3D%lu", (unsigned long)siz= e); + msg(M_FATAL, "fatal buffer size error, size=3D%zu", size); } struct buffer diff --git a/src/openvpn/mbuf.c b/src/openvpn/mbuf.c index 42858ec..9813237 100644 --- a/src/openvpn/mbuf.c +++ b/src/openvpn/mbuf.c @@ -34,11 +34,6 @@ #include "memdbg.h" -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - struct mbuf_set * mbuf_init(unsigned int size) { @@ -46,22 +41,17 @@ struct mbuf_set *ret; ALLOC_OBJ_CLEAR(ret, struct mbuf_set); - ret->capacity =3D adjust_power_of_2(size); + ret->capacity =3D (unsigned int)adjust_power_of_2(size); ALLOC_ARRAY(ret->array, struct mbuf_item, ret->capacity); return ret; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - void mbuf_free(struct mbuf_set *ms) { if (ms) { - int i; - for (i =3D 0; i < (int)ms->len; ++i) + for (unsigned int i =3D 0; i < ms->len; ++i) { struct mbuf_item *item =3D &ms->array[MBUF_INDEX(ms->head, i, = ms->capacity)]; mbuf_free_buf(item->buffer); @@ -145,8 +135,7 @@ struct multi_instance *ret =3D NULL; if (ms) { - int i; - for (i =3D 0; i < (int)ms->len; ++i) + for (unsigned int i =3D 0; i < ms->len; ++i) { struct mbuf_item *item =3D &ms->array[MBUF_INDEX(ms->head, i, = ms->capacity)]; if (item->instance) @@ -164,8 +153,7 @@ { if (ms) { - int i; - for (i =3D 0; i < (int)ms->len; ++i) + for (unsigned int i =3D 0; i < ms->len; ++i) { struct mbuf_item *item =3D &ms->array[MBUF_INDEX(ms->head, i, = ms->capacity)]; if (item->instance =3D=3D mi) -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1433?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: I1d4e0233cf1cb09725dbd2caa121acdbf62f0452 Gerrit-Change-Number: 1433 Gerrit-PatchSet: 3 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --HO5yd6nNVyg= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: plaisthos.

flichtenheld uploaded patch set #3 to this change.

<= p>View C= hange

mbuf: Fix conversion warnings in mbuf and relate=
d code

Mostly these were actually hidden by casts, but fix
them a= s well by using more fitting types.

Change-Id: I1d4e0233cf1cb09725db= d2caa121acdbf62f0452
Signed-off-by: Frank Lichtenheld <frank@...2724...= ..>
---
M src/openvpn/buffer.c
M src/openvpn/mbuf.c
2 files = changed, 6 insertions(+), 18 deletions(-)

git pu=
ll ssh://gerrit.openvpn.net:29418/openvpn refs/changes/33/1433/3
di=
ff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c
inde= x 40baca6..dca44d6 100644
--- a/src/openvpn/buffer.c=
+++ b/src/openvpn/buffer.c
@@ -43,7 +43,7 @@
unsigned long long res =3D
(unsig= ned long long)m1 * (unsigned long long)m2 + (unsigned long long)extra;
if (unlikely(m1 > limit) || unlikely(m2 > limit) || = unlikely(extra > limit)
- || unlikely(res > (unsigned long long)limit))
+ || unlikely(res > limi= t))

{
msg(M_FATAL, "atte= mpted allocation of excessively large array");
}<= /span>
@@ -53,7 +53,7 @@
void
bu= f_size_error(const size_t size)
{
- msg(M_FATAL, "fatal buffer size error= , size=3D%lu", (unsigned long)size);
+ msg(M_FATAL, "fatal buffer size error, size= =3D%zu", size);
}

= struct buffer
diff --git a/src/openvpn/mbuf.c b/src/openvpn= /mbuf.c
index 42858ec..9813237 100644
--- a= /src/openvpn/mbuf.c
+++ b/src/openvpn/mbuf.c
@@ -34,11 +34,6 @@


#include "memd= bg.h"

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wc= onversion"
-#endif=
-
str= uct mbuf_set *
mbuf_init(unsigned int size)
{

@@ -46,22 +41,17 @@

= struct mbuf_set *ret;
ALLOC_OBJ_CLEAR(ret, struct= mbuf_set);
- ret-&g= t;capacity =3D adjust_power_of_2(size);
+ ret->capacity =3D (unsigned int)adjust_power_of_= 2(size);
ALLOC_ARRAY(ret->array, struct mbuf_item, = ret->capacity);
return ret;
}

-#if defi= ned(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
void
mbuf_free(struct mbuf_set *ms)<= /span>
{
if (ms)
{
- int i;
<= span style=3D"color: hsl(0, 100%, 40%);">- for (i =3D 0; i < (int= )ms->len; ++i)

+ = for (unsigned int i =3D 0; i < ms->len; ++i)
= {
struct mbuf_item *item =3D &ms-&g= t;array[MBUF_INDEX(ms->head, i, ms->capacity)];
= mbuf_free_buf(item->buffer);
@@ -145,8 +135,7 @@=
struct multi_instance *ret =3D NULL;
= if (ms)
{
- int i;
- for (i =3D 0; i < (int)ms->len; ++i)
+ for (unsigned int i =3D 0; i = < ms->len; ++i)
{
= struct mbuf_item *item =3D &ms->array[MBUF_INDEX(ms->head, i, = ms->capacity)];
if (item->instance)
@@ -164,8 +153,7 @@
{
if = (ms)
{
- int i;
- = for (i =3D 0; i < (int)ms->len; ++i)
+ for (unsigned int i =3D 0; i < ms-= >len; ++i)
{
struc= t mbuf_item *item =3D &ms->array[MBUF_INDEX(ms->head, i, ms->c= apacity)];
if (item->instance =3D=3D mi)

To view, visit change 1433. To unsubscribe, o= r for help writing mail filters, visit settings.

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I1d4e0233cf1cb09725dbd2caa12= 1acdbf62f0452
Gerrit-Change-Number: 1433
Gerrit-PatchSet: 3
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...>
= --HO5yd6nNVyg=--