summaryrefslogtreecommitdiff
path: root/utilities
diff options
context:
space:
mode:
authorJoe Stringer <joe@ovn.org>2017-08-17 14:26:27 -0700
committerJoe Stringer <joe@ovn.org>2017-08-21 11:41:53 -0700
commit3f9e248f6ea57b1b32c35f6e1803c4cadd557220 (patch)
treeb158774dc70a282ad608de6f551ebfb889701beb /utilities
parent63d91afa92ef602fb2abcae1281910966d88d2b7 (diff)
downloadopenvswitch-3f9e248f6ea57b1b32c35f6e1803c4cadd557220.tar.gz
checkpatch: Enforce bracing around conditionals.
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>
Diffstat (limited to 'utilities')
-rwxr-xr-xutilities/checkpatch.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
index 43f10bb3d..185ddaf0d 100755
--- a/utilities/checkpatch.py
+++ b/utilities/checkpatch.py
@@ -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