[Openvpn-devel,v1] tun: Remove one useless if check

Message ID 20260508153458.13848-1-gert@greenie.muc.de
State New
Headers
Series [Openvpn-devel,v1] tun: Remove one useless if check |

Commit Message

Gert Doering May 8, 2026, 3:34 p.m. UTC
  From: Frank Lichtenheld <frank@lichtenheld.com>

The condition was already checked in an outer if check.

Identified by cppcheck.

Change-Id: I0aeb4583707a80592ec2577fbb060f7fbcb73e48
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1677
---

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/+/1677
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <gert@greenie.muc.de>
  

Comments

Gert Doering May 11, 2026, 5:12 p.m. UTC | #1
And indeed, cppcheck is right again... - best seen with "git show -w -U12"
(... I guess the outer clause was something like "DCO or wintun" at some
point in time...).

It's technically not even a bug just an ugly bit of code, so not backporting 
to release/2.7

Not tested.  Just stared at code, and at "buildbot all green"... *ahem*...
on Ubuntu, that is - the build fail on FreeBSD 14 is caused by 1675 v2,
and this one has not been pushed again.  t_client tested on FreeBSD :-)

Your patch has been applied to the master branch.

commit 1400926adada824973a3df001fdcc46f523d90ee
Author: Frank Lichtenheld
Date:   Fri May 8 17:34:53 2026 +0200

     tun: Remove one useless if check

     Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1677
     Message-Id: <20260508153458.13848-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg36867.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering
  

Patch

diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
index f46802f..e7193d8 100644
--- a/src/openvpn/tun.c
+++ b/src/openvpn/tun.c
@@ -5772,13 +5772,10 @@ 
                 continue;
             }
 
-            if (tt->backend_driver == DRIVER_DCO)
+            const char *last_sep = strrchr(dev_if->device_interface, '\\');
+            if (!last_sep || strcmp(last_sep + 1, DCO_WIN_REFERENCE_STRING) != 0)
             {
-                char *last_sep = strrchr(dev_if->device_interface, '\\');
-                if (!last_sep || strcmp(last_sep + 1, DCO_WIN_REFERENCE_STRING) != 0)
-                {
-                    continue;
-                }
+                continue;
             }
 
             path = dev_if->device_interface;