From b582af4b62325596231e9e34135b49c5115519e5 Mon Sep 17 00:00:00 2001 From: Jens Neuhalfen Date: Thu, 14 Apr 2016 19:58:07 +0200 Subject: [PATCH] Make intent of utun device name validation clear Make intend of the validation clear when validating utun parameter in open_darwin_utun. The program logic remains unchanged. Fixes the following compiler warning on Mac OS X: tun.c:2847:19: warning: logical not is only applied to the left hand side of this comparison [-Wlogical-not-parentheses] if (dev_node && !strcmp ("utun", dev_node)==0) ^ ~~ tun.c:2847:19: note: add parentheses after the '!' to evaluate the comparison first if (dev_node && !strcmp ("utun", dev_node)==0) ^ ( ) tun.c:2847:19: note: add parentheses around left hand side expression to silence this warning if (dev_node && !strcmp ("utun", dev_node)==0) ^ ( ) tun.c:2849:11: warning: logical not is only applied to the left hand side of this comparison [-Wlogical-not-parentheses] if (!sscanf (dev_node, "utun%d", &utunnum)==1) ^ ~~ tun.c:2849:11: note: add parentheses after the '!' to evaluate the comparison first if (!sscanf (dev_node, "utun%d", &utunnum)==1) ^ ( ) tun.c:2849:11: note: add parentheses around left hand side expression to silence this warning if (!sscanf (dev_node, "utun%d", &utunnum)==1) ^ ( ) Signed-off-by: Jens Neuhalfen Acked-by: Arne Schwabe Message-Id: <3365AB24-33FD-4D9D-A57C-BF9240DC3D69@neuhalfen.name> URL: http://article.gmane.org/gmane.network.openvpn.devel/11440 Signed-off-by: Gert Doering (cherry picked from commit 6be0f0015d7485f0bf3c14a3a381a6f6496270a5) --- src/openvpn/tun.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index bb019c085..b70410d20 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -2626,9 +2626,9 @@ open_darwin_utun (const char *dev, const char *dev_type, const char *dev_node, s /* dev_node is simply utun, do the normal dynamic utun * otherwise try to parse the utun number */ - if (dev_node && !strcmp ("utun", dev_node)==0) + if (dev_node && (strcmp("utun", dev_node) != 0 )) { - if (!sscanf (dev_node, "utun%d", &utunnum)==1) + if (sscanf(dev_node, "utun%d", &utunnum) != 1 ) msg (M_FATAL, "Cannot parse 'dev-node %s' please use 'dev-node utunX'" "to use a utun device number X", dev_node); } -- 2.47.2