From: "flichtenheld (Code Review)" Date: Fri, 12 Dec 2025 11:20:15 +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="6VJCiv6KKq0="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: manage: Avoid several conversion warnings by using the correct types List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --6VJCiv6KKq0= 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/+/1438?usp=3Demail to review the following change. Change subject: manage: Avoid several conversion warnings by using the corr= ect types ...................................................................... manage: Avoid several conversion warnings by using the correct types Change-Id: I0c5ef13d6fa6c1dd15da934a33e904c2fdacb731 Signed-off-by: Frank Lichtenheld --- M src/openvpn/manage.c 1 file changed, 10 insertions(+), 26 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/38/1438/1 diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index 6efa100..2191e55 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -206,11 +206,6 @@ return man->settings.up.defined && !man->connection.password_verified; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - static void man_check_password(struct management *man, const char *line) { @@ -220,7 +215,8 @@ * the attacker choice, it should not give any indication of the r= eal * password length, use + 1 to include the NUL byte that terminate= s the * string*/ - size_t compare_len =3D min_uint(strlen(line) + 1, sizeof(man->sett= ings.up.password)); + size_t compare_len =3D + min_size(strlen(line) + 1, sizeof(man->settings.up.password)); if (memcmp_constant_time(line, man->settings.up.password, compare_= len) =3D=3D 0) { man->connection.password_verified =3D true; @@ -241,10 +237,6 @@ } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - static void man_update_io_state(struct management *man) { @@ -2315,19 +2307,14 @@ #endif /* ifdef TARGET_ANDROID */ -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - -static int +static ssize_t man_read(struct management *man) { /* * read command line from socket */ unsigned char buf[256]; - int len =3D 0; + ssize_t len =3D 0; #ifdef TARGET_ANDROID int fd; @@ -2348,7 +2335,7 @@ { bool processed_command =3D false; - ASSERT(len <=3D (int)sizeof(buf)); + ASSERT(len <=3D (ssize_t)sizeof(buf)); command_line_add(man->connection.in, buf, (size_t)len); /* @@ -2414,11 +2401,11 @@ return len; } -static int +static ssize_t man_write(struct management *man) { const int size_hint =3D 1024; - int sent =3D 0; + ssize_t sent =3D 0; const struct buffer *buf; buffer_list_aggregate(man->connection.out, size_hint); @@ -2435,7 +2422,9 @@ } else #endif + { sent =3D send(man->connection.sd_cli, (const void *)BPTR(buf),= len, MSG_NOSIGNAL); + } if (sent >=3D 0) { buffer_list_advance(man->connection.out, sent); @@ -2457,10 +2446,6 @@ return sent; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - static void man_connection_clear(struct man_connection *mc) { @@ -3222,8 +3207,7 @@ if (net_events & FD_WRITE) { - int status; - status =3D man_write(man); + ssize_t status =3D man_write(man); if (status < 0 && WSAGetLastError() =3D=3D WSAEWOULDBL= OCK) { net_event_win32_clear_selected_events(&man->connec= tion.ne32, FD_WRITE); -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1438?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: I0c5ef13d6fa6c1dd15da934a33e904c2fdacb731 Gerrit-Change-Number: 1438 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --6VJCiv6KKq0= 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

manage: Avoid several conversion warnings b=
y using the correct types

Change-Id: I0c5ef13d6fa6c1dd15da934a33e904= c2fdacb731
Signed-off-by: Frank Lichtenheld <frank@...2641...>
= ---
M src/openvpn/manage.c
1 file changed, 10 insertions(+), 26 delet= ions(-)

git pull ssh://gerrit.openvpn.net:29418/=
openvpn refs/changes/38/1438/1
diff --git a/src/openvpn/manage.c b/=
src/openvpn/manage.c
index 6efa100..2191e55 100644--- a/src/openvpn/manage.c
+++ b/src/openvpn/manage= .c
@@ -206,11 +206,6 @@
return man->= ;settings.up.defined && !man->connection.password_verified;
}

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "= ;-Wconversion"

-#e= ndif
-
= static void
man_check_password(struct management *man, co= nst char *line)
{
@@ -220,7 +215,8 @@
* the attacker choice, it should not give any indicat= ion of the real
* password length, use + 1 to inc= lude the NUL byte that terminates the
* string*/<= /span>
- size_t compare= _len =3D min_uint(strlen(line) + 1, sizeof(man->settings.up.password));<= /span>
+ size_t compa= re_len =3D
+ = min_size(strlen(line) + 1, sizeof(man->settings.up.password));=
if (memcmp_constant_time(line, man->settings.up.passw= ord, compare_len) =3D=3D 0)
{
= man->connection.password_verified =3D true;
@@ = -241,10 +237,6 @@
}
}

-#if defined(__GNUC_= _) || defined(__clang__)
-#endif
-=
static void
man_update_io_state(struct manageme= nt *man)
{
@@ -2315,19 +2307,14 @@<= br>
#endif /* ifdef TARGET_ANDROID */

-#if defined(__GNU= C__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"-#endif
-
-static int
+static ssize_t
man_read(struct management *man) {
/*
* read command lin= e from socket
*/
unsigned char b= uf[256];
- int len = =3D 0;
+ ssize_t l= en =3D 0;

#ifdef TARGET_ANDROID int fd;
@@ -2348,7 +2335,7 @@
= {
bool processed_command =3D false;
- ASSER= T(len <=3D (int)sizeof(buf));
+ ASSERT(len <=3D (ssize_t)sizeof(buf));
command_line_add(man->connection.in, buf, (size_t)len);

/*
@@ -2414,11 +240= 1,11 @@
return len;
}

-static int+static ssize_t
man_write(struct management *man)
{
= const int size_hint =3D 1024;
- int sent =3D 0;
+ ssize_t sent =3D 0;
const struct buffer= *buf;

buffer_list_aggregate(man->= ;connection.out, size_hint);
@@ -2435,7 +2422,9 @@ }
else
#endif
+ {
sent =3D send(man->connection.sd_cli, (const void *)BPT= R(buf), len, MSG_NOSIGNAL);

+ }
if (sent >=3D 0)
{
buffer_list_advance(man->con= nection.out, sent);
@@ -2457,10 +2446,6 @@
= return sent;
}

-#if defined(__GNUC__) || defined(__clang__= )
-#pragma GCC diagnost= ic pop
-#endif-
static void<= /span>
man_connection_clear(struct man_connection *mc)
= {
@@ -3222,8 +3207,7 @@

= if (net_events & FD_WRITE)
= {
- = int status;
- status =3D man_write(man);
+ ssize_t status =3D man_wri= te(man);
if (status < 0 && = WSAGetLastError() =3D=3D WSAEWOULDBLOCK)
= {
net_event_win32_clear_selecte= d_events(&man->connection.ne32, FD_WRITE);

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

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I0c5ef13d6fa6c1dd15da934a33e= 904c2fdacb731
Gerrit-Change-Number: 1438
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...>
= --6VJCiv6KKq0=--