From: "cron2 (Code Review)" Date: Sat, 7 Mar 2026 09:11:03 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <4f64808f8ece5a3fa78e6aaa6381a7655e6d6d76-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="eDqr4UWiAZE="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Fix various sign-compare warnings due to write return value List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld , plaisthos Cc: openvpn-devel --eDqr4UWiAZE= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#4) to the change originally created by= flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1513?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by cron2 Change subject: Fix various sign-compare warnings due to write return value ...................................................................... Fix various sign-compare warnings due to write return value write takes size_t as count (unsigned int on Windows) and returns ssize_t (int on Windows). But we often want to compare the return value to the count. Generally we can just rely on the fact that sizeof(ssize_t) =3D=3D sizeof(size_t) and use that for all values. (Until we want to introduce -Wsign-conversion that is...) Change-Id: I3eb4581980f532cb2960b37a6fa43a7baee4b603 Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1513 Message-Id: <20260306163337.2756-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg35= 963.html Signed-off-by: Gert Doering --- M src/openvpn/ps.c M src/openvpn/status.c M src/plugins/auth-pam/auth-pam.c 3 files changed, 4 insertions(+), 30 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/13/1513/4 diff --git a/src/openvpn/ps.c b/src/openvpn/ps.c index c589248..c3f54ed 100644 --- a/src/openvpn/ps.c +++ b/src/openvpn/ps.c @@ -327,11 +327,6 @@ } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif - /* * Record IP/port of client in filesystem, so that server receiving * the proxy can determine true client origin. @@ -357,7 +352,8 @@ int fd =3D platform_open(jfn, O_CREAT | O_TRUNC | O_WRONLY, S_IRUS= R | S_IWUSR | S_IRGRP); if (fd !=3D -1) { - if (write(fd, f, strlen(f)) !=3D strlen(f)) + ssize_t write_len =3D strlen(f); + if (write(fd, f, write_len) !=3D write_len) { msg(M_WARN, "PORT SHARE: writing to journal file (%s) fail= ed", jfn); } @@ -373,10 +369,6 @@ } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - /* * Cleanup function, on proxy process exit. */ diff --git a/src/openvpn/status.c b/src/openvpn/status.c index 4d42863..c7d375b 100644 --- a/src/openvpn/status.c +++ b/src/openvpn/status.c @@ -206,11 +206,6 @@ return ret; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif - #define STATUS_PRINTF_MAXLEN 512 void @@ -240,7 +235,7 @@ if (so->fd >=3D 0 && !so->errors) { strcat(buf, "\n"); - size_t len =3D strlen(buf); + ssize_t len =3D strlen(buf); if (len > 0) { if (write(so->fd, buf, (unsigned int)len) !=3D len) @@ -258,10 +253,6 @@ } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - bool status_read(struct status_output *so, struct buffer *buf) { diff --git a/src/plugins/auth-pam/auth-pam.c b/src/plugins/auth-pam/auth-pa= m.c index 0f3346f..3b7bcc2 100644 --- a/src/plugins/auth-pam/auth-pam.c +++ b/src/plugins/auth-pam/auth-pam.c @@ -184,15 +184,10 @@ return -1; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif - static ssize_t send_string(int fd, const char *string) { - const size_t len =3D strlen(string) + 1; + const ssize_t len =3D strlen(string) + 1; const ssize_t size =3D write(fd, string, len); if (size =3D=3D len) { @@ -204,10 +199,6 @@ } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - #ifdef DO_DAEMONIZE =20 /* -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1513?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: I3eb4581980f532cb2960b37a6fa43a7baee4b603 Gerrit-Change-Number: 1513 Gerrit-PatchSet: 4 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel --eDqr4UWiAZE= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 upl= oaded patch set #4 to the change originally created by flichtenhel= d.

View Change

The following approvals got outdated and were remove= d: Code-Review+2 by cron2

Fix various sign-compare warnings d=
ue to write return value

write takes size_t as count (unsigned int o= n
Windows) and returns ssize_t (int on Windows).
But we often want to= compare the return value
to the count.

Generally we can just rel= y on the fact that
sizeof(ssize_t) =3D=3D sizeof(size_t) and use thatfor all values. (Until we want to introduce
-Wsign-conversion that is..= .)

Change-Id: I3eb4581980f532cb2960b37a6fa43a7baee4b603
Signed-of= f-by: Frank Lichtenheld <frank@...2641...>
Acked-by: Gert Doering = <gert@...1296...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn= /+/1513
Message-Id: <20260306163337.2756-1-gert@...1296...>
URL= : https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg35963= .html
Signed-off-by: Gert Doering <gert@...1296...>
---
M sr= c/openvpn/ps.c
M src/openvpn/status.c
M src/plugins/auth-pam/auth-pam= .c
3 files changed, 4 insertions(+), 30 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/13/151=
3/4
diff --git a/src/openvpn/ps.c b/src/openvpn/ps.c
index c589248..c3f54ed 100644
--- a/src/openvpn/ps.c

+++ b/src/openvpn/ps.c
@@ -327,11 +327,6 @@
}
}

-#if defined(__GNUC__) || defined(__clang= __)
-#pragma GCC diagno= stic push
-#pragma GCC = diagnostic ignored "-Wsign-compare"
-#endif
-
/*
* Record IP/port of client = in filesystem, so that server receiving
* the proxy can d= etermine true client origin.
@@ -357,7 +352,8 @@
= int fd =3D platform_open(jfn, O_CREAT | O_TRUNC | O_WRONLY, = S_IRUSR | S_IWUSR | S_IRGRP);
if (fd !=3D -1)
{
= - if (write(fd, f, strlen(f)) !=3D strlen(f))
+ ssize_t write_len =3D strl= en(f);
+ i= f (write(fd, f, write_len) !=3D write_len)
{
msg(M_WARN, "PORT SHARE: writing to jo= urnal file (%s) failed", jfn);
}@@ -373,10 +369,6 @@
}
}

-#if defi= ned(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
/*
* Cleanup function, on proxy pro= cess exit.
*/
diff --git a/src/openvpn/st= atus.c b/src/openvpn/status.c
index 4d42863..c7d375b 100644=
--- a/src/openvpn/status.c
+++ b/src/openv= pn/status.c
@@ -206,11 +206,6 @@
retur= n ret;
}

-#if defined(__GNUC__) || defined(__clang__)-#pragma GCC diagnostic push
-#pragma GCC diagnostic ig= nored "-Wsign-compare"
-#endif
-
#define STATUS_PRINTF_MAXLEN 512

= void
@@ -240,7 +235,7 @@
if= (so->fd >=3D 0 && !so->errors)
{=
strcat(buf, "\n");
- size_t len =3D strlen(buf)= ;
+ ssize_= t len =3D strlen(buf);
if (len > 0)<= br> {
if (write(so->f= d, buf, (unsigned int)len) !=3D len)
@@ -258,10 +253,6 @@
}
}

-#if defined(__GNUC__) || defined(__cla= ng__)
-#pragma GCC diag= nostic pop
-#endif
-
bool
status_read(struct status_output *so, struct buffer *buf)
{
diff --git a/src/plugins/auth-pam/auth-pam.= c b/src/plugins/auth-pam/auth-pam.c
index 0f3346f..3b7bcc2 = 100644
--- a/src/plugins/auth-pam/auth-pam.c
+++ b/src/plugins/auth-pam/auth-pam.c

@@ -184,15 +184,10 = @@
return -1;
}

-#if defined(__GNUC__) || = defined(__clang__)
-#pr= agma GCC diagnostic push
-#endif
-
static ssize_t
s= end_string(int fd, const char *string)
{
- const size_t len =3D strlen(string)= + 1;
+ const ssiz= e_t len =3D strlen(string) + 1;
const ssize_t size =3D= write(fd, string, len);
if (size =3D=3D len) {
@@ -204,10 +199,6 @@
}<= /span>
}

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
<= span style=3D"color: hsl(0, 100%, 40%);">-#endif

-
#ifdef DO_DAEMONIZE
=
/*

To view, vi= sit chan= ge 1513. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3eb4581980f532cb2960b37a6fa= 43a7baee4b603
Gerrit-Change-Number: 1513
Gerrit-PatchSet: 4
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --eDqr4UWiAZE=--