Make intent of device name validation clear
A message that is not in the archive (sent off-list or not yet received): [email protected]...
A message that is not in the archive (sent off-list or not yet received): [email protected]...
A message that is not in the archive (sent off-list or not yet received): [email protected]...
Am 15.04.16 um 18:41 schrieb Selva Nair:
Quoted 26 lines
On Fri, Apr 15, 2016 at 8:59 AM, Arne Schwabe <[email protected]... <mailto:[email protected]...>> wrote:
Am 14.04.16 um 19:58 schrieb Jens:
> Hi,
>
> please review the following patch for a compiler warning on MacOS X. The program logic is unchanged. Thanks for the patch.
Program logic is unchanged and the patch is fine but reading the fixed
code is more difficult.Instead of error of if not A you have now need to stare bit more to get that meaning.
I disagree.
Although if ( !strcmp() ) is a common usage in C, ( !srtcmp() == 0 ) is not, and such double negatives are best avoided.
strcmp()== 0 andstrcmp()!= 0 are easily understood by C-programmers.As for the scanf line, the original is
if (!sscanf (
dev_node, "utun%d", &utunnum)==1)
Quoted 8 lines
Here sscanf can potentially return EOF or 0 for failure or 1 for success, but the test catches only 0. EOF can result if
dev_node== "" or "tun", so probably unlikely (?) because of previous checks. In any case. the intent appears to be to catchsscanf()!= 1. And the latter is much better and easier to read.If its only a question of style, the patch clearly improves the unusual usage in the original, imo.
Fine. I am not going to nitpick here. Lets just say ACK to the original patch as it fixes the compiler warnings.
Arne
Thanks.
Your patch has been applied to the master and release/2.3 branch.
("Reluctantly-Acked-By: Arne Schwabe <[email protected]...>" :) )
commit 6be0f0015d7485f0bf3c14a3a381a6f6496270a5 (master) commit b582af4b62325596231e9e34135b49c5115519e5 (release/2.3)
Author: Jens Date: Thu Apr 14 19:58:07 2016 +0200
Make intent of device name validation clear
Signed-off-by: Jens Neuhalfen <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11440
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering