]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Remove various redundant conditionals
authorFrank Lichtenheld <frank@lichtenheld.com>
Sun, 19 Apr 2026 13:51:11 +0000 (15:51 +0200)
committerGert Doering <gert@greenie.muc.de>
Sun, 19 Apr 2026 15:51:47 +0000 (17:51 +0200)
These are all already proven to be true by
surrounding code.

Identified by cppcheck.

Change-Id: Iacf06c113e8db5b7c78270f361ee76938ef1db47
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1613
Message-Id: <20260419135116.22170-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg36666.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/manage.c
src/openvpn/multi.c
src/openvpn/options.c
src/openvpn/platform.c
src/openvpn/ssl_verify.c
src/openvpnserv/interactive.c

index c22a2a48852f098aa8ecf60a01b662d1c8f21635..2a3023c8ece473733959d7aeb69d0ef6614c8edd 100644 (file)
@@ -1625,10 +1625,7 @@ man_dispatch_command(struct management *man, struct status_output *so, const cha
         }
         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 @@ man_write(struct management *man)
         {
             buffer_list_advance(man->connection.out, sent);
         }
-        else if (sent < 0)
+        else
         {
             if (man_io_error(man, "send"))
             {
index fe210ee9bd8b284747f77c39621e98198e557ae3..06e37582a5698ea9691f524117f7992a44645b7f 100644 (file)
@@ -1837,7 +1837,7 @@ multi_client_set_protocol_options(struct context *c)
     {
         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 "
index 70af6d2b45281c224a2aae11a9d495c10806459b..0c2866cd2db0d4da1d85e4610ecf51f48366905d 100644 (file)
@@ -5304,7 +5304,7 @@ check_dns_option(struct options *options, char *p[], const msglvl_t msglevel, bo
         struct dns_server *server =
             dns_server_get(&options->dns_options.servers, priority, &options->dns_options.gc);
 
-        if (streq(p[3], "address") && p[4])
+        if (streq(p[3], "address"))
         {
             for (int i = 4; p[i]; ++i)
             {
index 3a6b272017ec944fefa36bfbc7b72ea70fce8203..9fa93636235e8586b6e296e0513eb33c8d836fe7 100644 (file)
@@ -572,7 +572,7 @@ platform_create_temp_file(const char *directory, const char *prefix, struct gc_a
             close(fd);
             return retfname;
         }
-        else if (fd == -1 && errno != EEXIST)
+        else if (errno != EEXIST)
         {
             /* Something else went wrong, no need to retry.  */
             msg(M_WARN | M_ERRNO, "Could not create temporary file '%s'", retfname);
index 21b516d9de8feee90dc36ed956821c764047e3c5..0804d2dd749792d38a21d03af5e6cb0cb0bc8828 100644 (file)
@@ -906,7 +906,7 @@ key_state_check_auth_pending_file(struct auth_deferred_status *ads,
         {
             /* Must have 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->head->next->next)
             {
                 msg(M_WARN, "auth pending control file is not at least "
                             "three lines long.");
index 4268214f4eac3f7433d47151f347ff1224fa20ea..473a8d33299d9911ea27fa6c7ee4837980230955 100644 (file)
@@ -486,7 +486,7 @@ GetStartupData(HANDLE pipe, STARTUP_DATA *sud)
     sud->directory = data;
     len = wcslen(sud->directory) + 1;
     size -= len;
-    if (size <= 0)
+    if (size == 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 @@ GetStartupData(HANDLE pipe, STARTUP_DATA *sud)
     sud->options = sud->directory + len;
     len = wcslen(sud->options) + 1;
     size -= len;
-    if (size <= 0)
+    if (size == 0)
     {
         MsgToEventLog(M_ERR, L"Startup data ends at command line options");
         ReturnError(pipe, ERROR_STARTUP_DATA, L"GetStartupData", 1, &exit_event);