Skip to contentSkip to conversation

Change in openvpn[master]: tun: Remove one useless if check

Openvpn-devel In review flichtenheld (Code Review) 2 participants 6 messages May 8 – May 11 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1778239616000.I0aeb4583707a80592ec2577fbb060f7fbcb73e48@...2715...

#1 lore raw

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/+/1677?usp=email

to review the following change.

Change subject: tun: Remove one useless if check
......................................................................

tun: Remove one useless if check

The condition was already checked in an outer if check.

Identified by cppcheck.

Change-Id I0aeb4583707a80592ec2577fbb060f7fbcb73e48

---
M src/openvpn/tun.c

1 file changed, 3 insertions(+), 6 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/77/1677/1

src/openvpn/tun.c +3 -6
index f46802f..e7193d8 100644
@@ -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;

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1677?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I0aeb4583707a80592ec2577fbb060f7fbcb73e48
Gerrit-Change-Number: 1677
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1677?usp=email )

Change subject: tun: Remove one useless if check
......................................................................

Patch Set 1: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1677?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I0aeb4583707a80592ec2577fbb060f7fbcb73e48
Gerrit-Change-Number: 1677
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Fri, 08 May 2026 15:34:43 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

#3 lore raw

PATCH 1/1 tun: Remove one useless if check

In reply to a message not in the archive

From: Frank Lichtenheld <[email protected]...>

The condition was already checked in an outer if check.

Identified by cppcheck.

Change-Id I0aeb4583707a80592ec2577fbb060f7fbcb73e48

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 <[email protected]...>

src/openvpn/tun.c +3 -6
index f46802f..e7193d8 100644
@@ -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;
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: tun: Remove one useless if check

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 <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1677
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg36867.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#2) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1677?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2

Change subject: tun: Remove one useless if check
......................................................................

tun: Remove one useless if check

The condition was already checked in an outer if check.

Identified by cppcheck.

Change-Id I0aeb4583707a80592ec2577fbb060f7fbcb73e48

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1677
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36867.html

---
M src/openvpn/tun.c

1 file changed, 3 insertions(+), 6 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/77/1677/2

src/openvpn/tun.c +3 -6
index f46802f..e7193d8 100644
@@ -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;

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1677?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I0aeb4583707a80592ec2577fbb060f7fbcb73e48
Gerrit-Change-Number: 1677
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1677?usp=email )

Change subject: tun: Remove one useless if check
......................................................................

tun: Remove one useless if check

The condition was already checked in an outer if check.

Identified by cppcheck.

Change-Id I0aeb4583707a80592ec2577fbb060f7fbcb73e48

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1677
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36867.html

---
M src/openvpn/tun.c

1 file changed, 3 insertions(+), 6 deletions(-)
src/openvpn/tun.c +3 -6
index f46802f..e7193d8 100644
@@ -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;

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1677?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I0aeb4583707a80592ec2577fbb060f7fbcb73e48
Gerrit-Change-Number: 1677
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>