mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 06:15:47 +00:00
checkpatch: Also check switch, HMAP_FOR_EACH, etc.
The switch statement and our FOR_EACH macro iteration constructs have the same rules as if, for, and while. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Aaron Conole <aconole@redhat.com>
This commit is contained in:
@@ -62,18 +62,26 @@ def print_warning(message):
|
||||
__warnings = __warnings + 1
|
||||
|
||||
|
||||
# These are keywords whose names are normally followed by a space and
|
||||
# something in parentheses (usually an expression) then a left curly brace.
|
||||
#
|
||||
# 'do' almost qualifies but it's also used as "do { ... } while (...);".
|
||||
__parenthesized_constructs = 'if|for|while|switch|[_A-Z]+FOR_EACH[_A-Z]*'
|
||||
|
||||
__regex_added_line = re.compile(r'^\+{1,2}[^\+][\w\W]*')
|
||||
__regex_subtracted_line = re.compile(r'^\-{1,2}[^\-][\w\W]*')
|
||||
__regex_leading_with_whitespace_at_all = re.compile(r'^\s+')
|
||||
__regex_leading_with_spaces = re.compile(r'^ +[\S]+')
|
||||
__regex_trailing_whitespace = re.compile(r'[^\S]+$')
|
||||
__regex_single_line_feed = re.compile(r'^\f$')
|
||||
__regex_for_if_missing_whitespace = re.compile(r' +(if|for|while)[\(]')
|
||||
__regex_for_if_too_much_whitespace = re.compile(r' +(if|for|while) +[\(]')
|
||||
__regex_for_if_missing_whitespace = re.compile(r' +(%s)[\(]'
|
||||
% __parenthesized_constructs)
|
||||
__regex_for_if_too_much_whitespace = re.compile(r' +(%s) +[\(]'
|
||||
% __parenthesized_constructs)
|
||||
__regex_for_if_parens_whitespace = \
|
||||
re.compile(r' +(if|for|while) \( +[\s\S]+\)')
|
||||
re.compile(r' +(%s) \( +[\s\S]+\)' % __parenthesized_constructs)
|
||||
__regex_is_for_if_single_line_bracket = \
|
||||
re.compile(r'^ +(if|for|while) \(.*\)')
|
||||
re.compile(r'^ +(%s) \(.*\)' % __parenthesized_constructs)
|
||||
__regex_ends_with_bracket = \
|
||||
re.compile(r'[^\s]\) {(\s+/\*[\s\Sa-zA-Z0-9\.,\?\*/+-]*)?$')
|
||||
__regex_ptr_declaration_missing_whitespace = re.compile(r'[a-zA-Z0-9]\*[^*]')
|
||||
|
Reference in New Issue
Block a user