From: "flichtenheld (Code Review)" Date: Mon, 9 Mar 2026 16:29:14 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <6b9018bd610dfa2705c0d984a32a0e739aaead46-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="WIG941kFxTw="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: init: Avoid sign-compare warnings List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --WIG941kFxTw= 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/+/1562?usp=3Demail to review the following change. Change subject: init: Avoid sign-compare warnings ...................................................................... init: Avoid sign-compare warnings - Use BLENZ instead of buf_len where applicable - Fix some comparisons with ce list length Change-Id: Ie0b94b596637d660392bc4eda48d16cfecfeb971 Signed-off-by: Frank Lichtenheld --- M src/openvpn/init.c 1 file changed, 6 insertions(+), 16 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/62/1562/1 diff --git a/src/openvpn/init.c b/src/openvpn/init.c index 34ed4eb..66a5836 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -325,11 +325,6 @@ return l->len; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif - static bool management_callback_remote_entry_get(void *arg, unsigned int index, char *= *remote) { @@ -340,7 +335,7 @@ struct connection_list *l =3D c->options.connection_list; bool ret =3D true; - if (index < l->len) + if (l->len > 0 && index < (unsigned int)l->len) { struct connection_entry *ce =3D l->array[index]; const char *proto =3D proto2ascii(ce->proto, ce->af, false); @@ -364,10 +359,6 @@ return ret; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - static bool management_callback_remote_cmd(void *arg, const char **p) { @@ -466,7 +457,6 @@ #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" -#pragma GCC diagnostic ignored "-Wsign-compare" #endif /* @@ -638,8 +628,8 @@ } while (!ce_defined); /* Check if this connection attempt would bring us over the limit */ - if (c->options.connect_retry_max > 0 - && c->options.unsuccessful_attempts > (l->len * c->options.connect= _retry_max)) + int max_attempts =3D l->len * c->options.connect_retry_max; + if (max_attempts > 0 && c->options.unsuccessful_attempts > (unsigned i= nt)max_attempts) { msg(M_FATAL, "All connections have been connect-retry-max (%d) tim= es unsuccessful, exiting", c->options.connect_retry_max); @@ -2176,7 +2166,7 @@ static void add_delim_if_non_empty(struct buffer *buf, const char *header) { - if (buf_len(buf) > strlen(header)) + if (BLENZ(buf) > strlen(header)) { buf_printf(buf, ", "); } @@ -2264,7 +2254,7 @@ buf_printf(&out, "session-timeout %d", o->session_timeout); } - if (buf_len(&out) > strlen(header)) + if (BLENZ(&out) > strlen(header)) { msg(D_HANDSHAKE, "%s", BSTR(&out)); } @@ -2301,7 +2291,7 @@ } } - if (buf_len(&out) > strlen(header)) + if (BLENZ(&out) > strlen(header)) { msg(D_HANDSHAKE, "%s", BSTR(&out)); } -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1562?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: Ie0b94b596637d660392bc4eda48d16cfecfeb971 Gerrit-Change-Number: 1562 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --WIG941kFxTw= 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

init: Avoid sign-compare warnings

- = Use BLENZ instead of buf_len where applicable
- Fix some comparisons wit= h ce list length

Change-Id: Ie0b94b596637d660392bc4eda48d16cfecfeb97= 1
Signed-off-by: Frank Lichtenheld <frank@...2641...>
---
M = src/openvpn/init.c
1 file changed, 6 insertions(+), 16 deletions(-)
<= br>
git pull ssh://gerrit.openvpn.net:29418/openvpn refs=
/changes/62/1562/1
diff --git a/src/openvpn/init.c b/src/openvpn/in=
it.c
index 34ed4eb..66a5836 100644
--- a/sr= c/openvpn/init.c
+++ b/src/openvpn/init.c
@= @ -325,11 +325,6 @@
return l->len;
= }

-#= if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wsign-comp= are"
-#endif
-
static bo= ol
management_callback_remote_entry_get(void *arg, unsigne= d int index, char **remote)
{
@@ -340,7 +3= 35,7 @@
struct connection_list *l =3D c->options.co= nnection_list;
bool ret =3D true;

- if (index < l->= ;len)
+ if (l->= len > 0 && index < (unsigned int)l->len)
= {
struct connection_entry *ce =3D l->array[= index];
const char *proto =3D proto2ascii(ce->p= roto, ce->af, false);
@@ -364,10 +359,6 @@
return ret;

}

-#if defined(__GNUC__) || defined(__clang= __)
-#pragma GCC diagno= stic pop
-#endif=
-
static boo= l
management_callback_remote_cmd(void *arg, const char **p= )
{
@@ -466,7 +457,6 @@
#= if defined(__GNUC__) || defined(__clang__)
#pragma GCC dia= gnostic push
#pragma GCC diagnostic ignored "-Wconver= sion"
-#pragma GCC= diagnostic ignored "-Wsign-compare"
#endif

/*
@@ -638,8 +628,8 @@
} while (!ce_defined);

= /* Check if this connection attempt would bring us over the limit */
- if (c->options.con= nect_retry_max > 0
-= && c->options.unsuccessful_attempts > (l->len * c-= >options.connect_retry_max))
+ int max_attempts =3D l->len * c->options.connect_retr= y_max;
+ if (max_a= ttempts > 0 && c->options.unsuccessful_attempts > (unsigne= d int)max_attempts)
{
msg(M_F= ATAL, "All connections have been connect-retry-max (%d) times unsucces= sful, exiting",
c->options.connect_ret= ry_max);
@@ -2176,7 +2166,7 @@
static void=
add_delim_if_non_empty(struct buffer *buf, const char *he= ader)
{
+ if (BLENZ(buf) > strlen(header))
= {
buf_printf(buf, ", ");
}
@@ -2264,7 +2254,7 @@
= buf_printf(&out, "session-timeout %d", o->session_t= imeout);
}

- if (buf_len(&out) > strlen(header))<= /span>
+ if (BLENZ(&o= ut) > strlen(header))
{
ms= g(D_HANDSHAKE, "%s", BSTR(&out));
}
@@ -2301,7 +2291,7 @@
}
}


- if (buf_len(&out) > strlen(header))
+ if (BLENZ(&out) > strlen(heade= r))
{
msg(D_HANDSHAKE, "= %s", BSTR(&out));
}

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

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie0b94b596637d660392bc4eda48= d16cfecfeb971
Gerrit-Change-Number: 1562
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...>
= --WIG941kFxTw=--