[Openvpn-devel,v1] manage: drop redundant NULL checks

Message ID 20261123134906.31644-1-gert@greenie.muc.de
State New
Headers
Series [Openvpn-devel,v1] manage: drop redundant NULL checks |

Commit Message

Gert Doering Nov. 23, 2026, 1:49 p.m. UTC
  From: Razvan Cojocaru <razvanc@mailbox.org>

man_need() already guarantees p[1] for log and echo, and
up_query_type is non-NULL once "needed" holds in
man_query_password_base64().

Change-Id: I58b88ca3934e52cfc5140a564c9ed7260857ce80
Signed-off-by: Razvan Cojocaru <razvanc@mailbox.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2238
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2238
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <frank@lichtenheld.com>
  

Comments

Gert Doering Nov. 23, 2026, 6:39 p.m. UTC | #1
Indeed, good catches.  Checking something already guaranteed does not
help readers what is going on ;-)

No actual bug fixed, so cleanup, and no 2.7

Your patch has been applied to the master branch.

commit f7d89f63de3c40c24bb00e7894a882261c11c130
Author: Razvan Cojocaru
Date:   Mon Nov 23 14:49:01 2026 +0100

     manage: drop redundant NULL checks

     Signed-off-by: Razvan Cojocaru <razvanc@mailbox.org>
     Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2238
     Message-Id: <20261123134906.31644-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg41822.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering
  

Patch

diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c
index 86c498e..d5b1ff8 100644
--- a/src/openvpn/manage.c
+++ b/src/openvpn/manage.c
@@ -1051,7 +1051,7 @@ 
         msg(M_CLIENT, "ERROR: no password is currently needed at this time");
         return;
     }
-    if (!man->connection.up_query_type || !streq(man->connection.up_query_type, type))
+    if (!streq(man->connection.up_query_type, type))
     {
         msg(M_CLIENT, "ERROR: password of type '%s' entered, but we need one of type '%s'",
             type, man->connection.up_query_type);
@@ -1684,10 +1684,7 @@ 
     {
         if (man_need(p, 1, MN_AT_LEAST))
         {
-            if (p[1])
-            {
-                man_log(man, p[1]);
-            }
+            man_log(man, p[1]);
             if (p[2])
             {
                 man_log(man, p[2]);
@@ -1698,10 +1695,7 @@ 
     {
         if (man_need(p, 1, MN_AT_LEAST))
         {
-            if (p[1])
-            {
-                man_echo(man, p[1]);
-            }
+            man_echo(man, p[1]);
             if (p[2])
             {
                 man_echo(man, p[2]);