From: "cron2 (Code Review)" Date: Sun, 19 Apr 2026 15:56:07 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <925fa506e239403e9f0e62bbb4c68b8db25c9cd5-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="5sCjK2P0H8A="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Remove various redundant conditionals List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld , plaisthos Cc: openvpn-devel --5sCjK2P0H8A= 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/+/1613?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by cron2 Change subject: Remove various redundant conditionals ...................................................................... Remove various redundant conditionals These are all already proven to be true by surrounding code. Identified by cppcheck. Change-Id: Iacf06c113e8db5b7c78270f361ee76938ef1db47 Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1613 Message-Id: <20260419135116.22170-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg36= 666.html Signed-off-by: Gert Doering --- M src/openvpn/manage.c M src/openvpn/multi.c M src/openvpn/options.c M src/openvpn/platform.c M src/openvpn/ssl_verify.c M src/openvpnserv/interactive.c 6 files changed, 8 insertions(+), 11 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/13/1613/4 diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index c22a2a4..2a3023c 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -1625,10 +1625,7 @@ } else { - if (p[1]) - { - man_state(man, p[1]); - } + man_state(man, p[1]); if (p[2]) { man_state(man, p[2]); @@ -2542,7 +2539,7 @@ { buffer_list_advance(man->connection.out, sent); } - else if (sent < 0) + else { if (man_io_error(man, "send")) { diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index fe210ee..06e3758 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -1837,7 +1837,7 @@ { msg(M_INFO, "PUSH: No NCP or OCC cipher data received from peer."); - if (o->enable_ncp_fallback && !tls_multi->remote_ciphername) + if (o->enable_ncp_fallback) { msg(M_INFO, "Using data channel cipher '%s' since " diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 70af6d2..0c2866c 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -5304,7 +5304,7 @@ struct dns_server *server =3D dns_server_get(&options->dns_options.servers, priority, &optio= ns->dns_options.gc); - if (streq(p[3], "address") && p[4]) + if (streq(p[3], "address")) { for (int i =3D 4; p[i]; ++i) { diff --git a/src/openvpn/platform.c b/src/openvpn/platform.c index 3a6b272..9fa9363 100644 --- a/src/openvpn/platform.c +++ b/src/openvpn/platform.c @@ -572,7 +572,7 @@ close(fd); return retfname; } - else if (fd =3D=3D -1 && errno !=3D EEXIST) + else if (errno !=3D EEXIST) { /* Something else went wrong, no need to retry. */ msg(M_WARN | M_ERRNO, "Could not create temporary file '%s'", = retfname); diff --git a/src/openvpn/ssl_verify.c b/src/openvpn/ssl_verify.c index 21b516d..0804d2d 100644 --- a/src/openvpn/ssl_verify.c +++ b/src/openvpn/ssl_verify.c @@ -906,7 +906,7 @@ { /* Must have at least three lines. further lines are ignored f= or * forward compatibility */ - if (!lines->head || !lines->head->next || !lines->head->next->= next) + if (!lines->head->next || !lines->head->next->next) { msg(M_WARN, "auth pending control file is not at least " "three lines long."); diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c index 4268214..473a8d3 100644 --- a/src/openvpnserv/interactive.c +++ b/src/openvpnserv/interactive.c @@ -486,7 +486,7 @@ sud->directory =3D data; len =3D wcslen(sud->directory) + 1; size -=3D len; - if (size <=3D 0) + if (size =3D=3D 0) { MsgToEventLog(M_ERR, L"Startup data ends at working directory"); ReturnError(pipe, ERROR_STARTUP_DATA, L"GetStartupData", 1, &exit_= event); @@ -496,7 +496,7 @@ sud->options =3D sud->directory + len; len =3D wcslen(sud->options) + 1; size -=3D len; - if (size <=3D 0) + if (size =3D=3D 0) { MsgToEventLog(M_ERR, L"Startup data ends at command line options"); ReturnError(pipe, ERROR_STARTUP_DATA, L"GetStartupData", 1, &exit_= event); -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1613?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: Iacf06c113e8db5b7c78270f361ee76938ef1db47 Gerrit-Change-Number: 1613 Gerrit-PatchSet: 4 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel --5sCjK2P0H8A= 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

Remove various redundant conditiona=
ls

These are all already proven to be true by
surrounding code.
Identified by cppcheck.

Change-Id: Iacf06c113e8db5b7c78270f361= ee76938ef1db47
Signed-off-by: Frank Lichtenheld <frank@...2641...>=
Acked-by: Gert Doering <gert@...1296...>
Gerrit URL: https://g= errit.openvpn.net/c/openvpn/+/1613
Message-Id: <20260419135116.22170-= 1-gert@...1296...>
URL: https://www.mail-archive.com/openvpn-devel@...1224...= sts.sourceforge.net/msg36666.html
Signed-off-by: Gert Doering <gert@...220...= ..1296...>
---
M src/openvpn/manage.c
M src/openvpn/multi.c
= M src/openvpn/options.c
M src/openvpn/platform.c
M src/openvpn/ssl_ve= rify.c
M src/openvpnserv/interactive.c
6 files changed, 8 insertions(= +), 11 deletions(-)

git pull ssh://gerrit.openvp=
n.net:29418/openvpn refs/changes/13/1613/4
diff --git a/src/openvpn=
/manage.c b/src/openvpn/manage.c
index c22a2a4..2a3023c 100= 644
--- a/src/openvpn/manage.c
+++ b/src/op= envpn/manage.c
@@ -1625,10 +1625,7 @@
= }
else
{
- if (p[1])
- {
- man_state(man, p[1]);
- }
+ man_state(man, p[1])= ;

if (p[2])
{
man_state(man, p[2]);
@@ -254= 2,7 +2539,7 @@
{
buff= er_list_advance(man->connection.out, sent);
}
- else if (sent &= lt; 0)
+ else<= /span>
{
if (man_io_error(ma= n, "send"))
{
diff -= -git a/src/openvpn/multi.c b/src/openvpn/multi.c
index fe21= 0ee..06e3758 100644
--- a/src/openvpn/multi.c
+++ b/src/openvpn/multi.c

@@ -1837,7 +1837,7 @@ {
msg(M_INFO, "PUSH: No NCP or O= CC cipher data received from peer.");

- if (o->enable_ncp_fallbac= k && !tls_multi->remote_ciphername)

+ if (o->enable_ncp_fallback) {
msg(M_INFO,
= "Using data channel cipher '%s' since "<= /span>
diff --git a/src/openvpn/options.c b/src/openvpn/options.c<= /span>
index 70af6d2..0c2866c 100644
--- a/src/ope= nvpn/options.c
+++ b/src/openvpn/options.c
= @@ -5304,7 +5304,7 @@
struct dns_server *server = =3D
dns_server_get(&options->dns_option= s.servers, priority, &options->dns_options.gc);

- if (streq(p[3], = "address") && p[4])
+ if (streq(p[3], "address"))
<= span> {
for (int i =3D 4; p[i]; ++i)
{
diff --git a/src/openvpn/plat= form.c b/src/openvpn/platform.c
index 3a6b272..9fa9363 1006= 44
--- a/src/openvpn/platform.c
+++ b/src/o= penvpn/platform.c
@@ -572,7 +572,7 @@
= close(fd);
return retfname;
= }
- = else if (fd =3D=3D -1 && errno !=3D EEXIST)
+ else if (errno !=3D EEXIST)
{
/* Something else went = wrong, no need to retry. */
msg(M_WARN | M_ER= RNO, "Could not create temporary file '%s'", retfname);
diff --git a/src/openvpn/ssl_verify.c b/src/openvpn/ssl_veri= fy.c
index 21b516d..0804d2d 100644
--- a/sr= c/openvpn/ssl_verify.c
+++ b/src/openvpn/ssl_verify.c
@@ -906,7 +906,7 @@
{
= /* Must have at least three lines. further lines are ignored fo= r
* forward compatibility */
- if (!lines->head || !li= nes->head->next || !lines->head->next->next)
+ if (!lines->head->= ;next || !lines->head->next->next)

{<= /span>
msg(M_WARN, "auth pending control fil= e is not at least "
"= ;three lines long.");
diff --git a/src/openvpnserv/int= eractive.c b/src/openvpnserv/interactive.c
index 4268214..4= 73a8d3 100644
--- a/src/openvpnserv/interactive.c+++ b/src/openvpnserv/interactive.c
@@ -486,7 +486,7= @@
sud->directory =3D data;
l= en =3D wcslen(sud->directory) + 1;
size -=3D len;
- if (size <=3D 0)=
+ if (size =3D=3D= 0)
{
MsgToEventLog(M_ERR, L&= quot;Startup data ends at working directory");
= ReturnError(pipe, ERROR_STARTUP_DATA, L"GetStartupData", 1, &am= p;exit_event);
@@ -496,7 +496,7 @@
sud= ->options =3D sud->directory + len;
len =3D wcsl= en(sud->options) + 1;
size -=3D len;
- if (size <=3D 0)

+ if (size =3D=3D 0)
{
MsgToEventLog(M_ERR, L"Startup = data ends at command line options");
ReturnEr= ror(pipe, ERROR_STARTUP_DATA, L"GetStartupData", 1, &exit_eve= nt);

To view, visit change 1613. To unsubsc= ribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iacf06c113e8db5b7c78270f361e= e76938ef1db47
Gerrit-Change-Number: 1613
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>
= --5sCjK2P0H8A=--