From: "flichtenheld (Code Review)" Date: Sun, 5 Apr 2026 20:39:32 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <4f2cccf635770788e5749919b258ee363650f4f7-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="e6nggZyKaAU="; 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: plaisthos Cc: openvpn-devel --e6nggZyKaAU= 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/+/1613?usp=3Demail to review the following change. 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 --- 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/1 diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index 6cab7db..d776908 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -1551,10 +1551,7 @@ } else { - if (p[1]) - { - man_state(man, p[1]); - } + man_state(man, p[1]); if (p[2]) { man_state(man, p[2]); @@ -2457,7 +2454,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 22f8b54..7882f32 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -1869,7 +1869,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 713dcf4..200e3cd 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 d44f25f..99df49c 100644 --- a/src/openvpn/ssl_verify.c +++ b/src/openvpn/ssl_verify.c @@ -895,7 +895,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 c96d3f2..322461e 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: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Iacf06c113e8db5b7c78270f361ee76938ef1db47 Gerrit-Change-Number: 1613 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --e6nggZyKaAU= 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

Remove various redundant conditionals
These are all already proven to be true by
surrounding code.

Id= entified by cppcheck.

Change-Id: Iacf06c113e8db5b7c78270f361ee76938e= f1db47
Signed-off-by: Frank Lichtenheld <frank@...2641...>
---<= br>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/openv= pnserv/interactive.c
6 files changed, 8 insertions(+), 11 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn r=
efs/changes/13/1613/1
diff --git a/src/openvpn/manage.c b/src/openv=
pn/manage.c
index 6cab7db..d776908 100644
-= -- a/src/openvpn/manage.c
+++ b/src/openvpn/manage.c=
@@ -1551,10 +1551,7 @@
}
else
{
- if (p[1])
- {
- man_state(man, p[1]);
- }
+ man_state(man, p[1]);
= if (p[2])
{
= man_state(man, p[2]);
@@ -2457,7 +2454,7 @@=
{
buffer_list_advance(man-&= gt;connection.out, sent);
}
- else if (sent < 0)
+ else
= {
if (man_io_error(man, "send")= )
{
diff --git a/src/openvpn/m= ulti.c b/src/openvpn/multi.c
index 22f8b54..7882f32 100644<= /span>
--- a/src/openvpn/multi.c
+++ b/src/openvpn= /multi.c
@@ -1869,7 +1869,7 @@
{

msg(M_INFO, "PUSH: No NCP or OCC cipher data recei= ved from peer.");

- if (o->enable_ncp_fallback && !tls_mu= lti->remote_ciphername)
+ if (o->enable_ncp_fallback)
{
msg(M_INFO,
&qu= ot;Using data channel cipher '%s' since "
diff= --git a/src/openvpn/options.c b/src/openvpn/options.c
inde= x 713dcf4..200e3cd 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, &= amp;options->dns_options.gc);

- if (streq(p[3], "address") &= amp;& 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/p= latform.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 retr= y. */
msg(M_WARN | M_ERRNO, "Could not c= reate temporary file '%s'", retfname);
diff --= git a/src/openvpn/ssl_verify.c b/src/openvpn/ssl_verify.c
i= ndex d44f25f..99df49c 100644
--- a/src/openvpn/ssl_verify.c=
+++ b/src/openvpn/ssl_verify.c
@@ -895,7 += 895,7 @@
{
/* Must ha= ve at least three lines. further lines are ignored for
= * forward compatibility */
- if (!lines->head || !lines->head->next = || !lines->head->next->next)
+ if (!lines->head->next || !lines->he= ad->next->next)
{
= msg(M_WARN, "auth pending control file is not at least &quo= t;
"three lines long.&quo= t;);
diff --git a/src/openvpnserv/interactive.c b/src/openv= pnserv/interactive.c
index c96d3f2..322461e 100644--- a/src/openvpnserv/interactive.c
+++ b/src/openv= pnserv/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 en= ds 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_STAR= TUP_DATA, L"GetStartupData", 1, &exit_event);

To view, visit change 1613. To unsubscribe, or for help wr= iting mail filters, visit settings.

=
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iacf06c113e8db5b7c78270f361e= e76938ef1db47
Gerrit-Change-Number: 1613
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...>
= --e6nggZyKaAU=--