mirror of
https://github.com/openvswitch/ovs
synced 2025-09-04 16:25:17 +00:00
checkpatch: Check for C99 style comments.
Coding-style document asks not to use C99 ( '//' ) comments. Acked-by: Aaron Conole <aconole@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@samsung.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
@@ -287,3 +287,26 @@ try_checkpatch \
|
|||||||
"
|
"
|
||||||
|
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
|
AT_SETUP([checkpatch - comments])
|
||||||
|
try_checkpatch \
|
||||||
|
"COMMON_PATCH_HEADER
|
||||||
|
+ a = 1; /* C style comment. */
|
||||||
|
"
|
||||||
|
|
||||||
|
try_checkpatch \
|
||||||
|
"COMMON_PATCH_HEADER
|
||||||
|
+ /* http://URL/inside/the/comment.html */
|
||||||
|
"
|
||||||
|
|
||||||
|
try_checkpatch \
|
||||||
|
"COMMON_PATCH_HEADER
|
||||||
|
+ a = 1; // C99 style comment.
|
||||||
|
" \
|
||||||
|
"ERROR: C99 style comment
|
||||||
|
#8 FILE: A.c:1:
|
||||||
|
a = 1; // C99 style comment.
|
||||||
|
"
|
||||||
|
|
||||||
|
AT_CLEANUP
|
||||||
|
@@ -163,6 +163,7 @@ __regex_ends_with_bracket = \
|
|||||||
__regex_ptr_declaration_missing_whitespace = re.compile(r'[a-zA-Z0-9]\*[^*]')
|
__regex_ptr_declaration_missing_whitespace = re.compile(r'[a-zA-Z0-9]\*[^*]')
|
||||||
__regex_is_comment_line = re.compile(r'^\s*(/\*|\*\s)')
|
__regex_is_comment_line = re.compile(r'^\s*(/\*|\*\s)')
|
||||||
__regex_has_comment = re.compile(r'.*(/\*|\*\s)')
|
__regex_has_comment = re.compile(r'.*(/\*|\*\s)')
|
||||||
|
__regex_has_c99_comment = re.compile(r'.*//.*$')
|
||||||
__regex_trailing_operator = re.compile(r'^[^ ]* [^ ]*[?:]$')
|
__regex_trailing_operator = re.compile(r'^[^ ]* [^ ]*[?:]$')
|
||||||
__regex_conditional_else_bracing = re.compile(r'^\s*else\s*{?$')
|
__regex_conditional_else_bracing = re.compile(r'^\s*else\s*{?$')
|
||||||
__regex_conditional_else_bracing2 = re.compile(r'^\s*}\selse\s*$')
|
__regex_conditional_else_bracing2 = re.compile(r'^\s*}\selse\s*$')
|
||||||
@@ -298,6 +299,11 @@ def has_comment(line):
|
|||||||
return __regex_has_comment.match(line) is not None
|
return __regex_has_comment.match(line) is not None
|
||||||
|
|
||||||
|
|
||||||
|
def has_c99_comment(line):
|
||||||
|
"""Returns TRUE if the current line contains C99 style comment (//)."""
|
||||||
|
return __regex_has_c99_comment.match(line) is not None
|
||||||
|
|
||||||
|
|
||||||
def trailing_operator(line):
|
def trailing_operator(line):
|
||||||
"""Returns TRUE if the current line ends with an operatorsuch as ? or :"""
|
"""Returns TRUE if the current line ends with an operatorsuch as ? or :"""
|
||||||
return __regex_trailing_operator.match(line) is not None
|
return __regex_trailing_operator.match(line) is not None
|
||||||
@@ -545,6 +551,11 @@ checks = [
|
|||||||
'check': lambda x: has_xxx_mark(x),
|
'check': lambda x: has_xxx_mark(x),
|
||||||
'print': lambda: print_warning("Comment with 'xxx' marker")},
|
'print': lambda: print_warning("Comment with 'xxx' marker")},
|
||||||
|
|
||||||
|
{'regex': r'(\.c|\.h)(\.in)?$', 'match_name': None,
|
||||||
|
'prereq': lambda x: not is_comment_line(x),
|
||||||
|
'check': lambda x: has_c99_comment(x),
|
||||||
|
'print': lambda: print_error("C99 style comment")},
|
||||||
|
|
||||||
{'regex': r'(\.c|\.h)(\.in)?$', 'match_name': None,
|
{'regex': r'(\.c|\.h)(\.in)?$', 'match_name': None,
|
||||||
'prereq': lambda x: has_comment(x),
|
'prereq': lambda x: has_comment(x),
|
||||||
'check': lambda x: check_comment_spelling(x)},
|
'check': lambda x: check_comment_spelling(x)},
|
||||||
|
Reference in New Issue
Block a user