]> git.proxmox.com Git - ovs.git/commitdiff
checkpatch: Enforce bracing around conditionals.
authorJoe Stringer <joe@ovn.org>
Thu, 17 Aug 2017 21:26:27 +0000 (14:26 -0700)
committerJoe Stringer <joe@ovn.org>
Mon, 21 Aug 2017 18:41:53 +0000 (11:41 -0700)
The coding style states that BSD-style brace placement should be used,
and even single statements should be enclosed. Add checks to checkpatch
for this, particularly for 'else' statements.

Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Aaron Conole <aconole@redhat.com>
utilities/checkpatch.py

index 43f10bb3ded3ff0784bcc978321304c800b94eac..185ddaf0d5e95493b6df8ac4cd8b08c42f269cd9 100755 (executable)
@@ -95,6 +95,8 @@ __regex_ends_with_bracket = \
 __regex_ptr_declaration_missing_whitespace = re.compile(r'[a-zA-Z0-9]\*[^*]')
 __regex_is_comment_line = re.compile(r'^\s*(/\*|\*\s)')
 __regex_trailing_operator = re.compile(r'^[^ ]* [^ ]*[?:]$')
+__regex_conditional_else_bracing = re.compile(r'^\s*else\s*{?$')
+__regex_conditional_else_bracing2 = re.compile(r'^\s*}\selse\s*$')
 
 skip_leading_whitespace_check = False
 skip_trailing_whitespace_check = False
@@ -186,6 +188,10 @@ def if_and_for_end_with_bracket_check(line):
             return True
         if __regex_ends_with_bracket.search(line) is None:
             return False
+    if __regex_conditional_else_bracing.match(line) is not None:
+        return False
+    if __regex_conditional_else_bracing2.match(line) is not None:
+        return False
     return True