]> git.proxmox.com Git - ovs.git/commitdiff
checkpatch.py: Fix false positive on if/when/for
authorEric Garver <e@erig.me>
Thu, 16 Mar 2017 14:22:32 +0000 (10:22 -0400)
committerRussell Bryant <russell@ovn.org>
Thu, 16 Mar 2017 14:37:31 +0000 (10:37 -0400)
We need to use == instead of the is operator. If you're unlucky it may
fail because they're not exactly the same object, but hold the same
value.

Example false positive:

E(120): Inappropriate bracing around statement

+            if (0 != nl_attr_get_u8(vxlan[IFLA_VXLAN_LEARNING])

Fixes: 30c7ffd5ac46 ("utilities/checkpatch.py: Check for appropriate bracing")
Signed-off-by: Eric Garver <e@erig.me>
Signed-off-by: Russell Bryant <russell@ovn.org>
utilities/checkpatch.py

index dfe6f9c7621ebbedc90287fb46b9a4cd5c16a345..638ac97746b68d87122eb2e47d7001ce9a94c03b 100755 (executable)
@@ -144,11 +144,11 @@ def if_and_for_end_with_bracket_check(line):
         """This is a rather naive counter - it won't deal with quotes"""
         balance = 0
         for letter in line:
-            if letter is '(':
+            if letter == '(':
                 balance += 1
-            elif letter is ')':
+            elif letter == ')':
                 balance -= 1
-        return balance is 0
+        return balance == 0
 
     if __regex_is_for_if_single_line_bracket.search(line) is not None:
         if not balanced_parens(line):