2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-30 22:05:19 +00:00

python: Fix invalid escape sequences.

It appears that Python silently treats invalid escape sequences in
strings as literals, e.g. "\." is the same as "\\.".  Newer versions of
checkpatch complain, and it does seem reasonable to me to fix these.

Acked-by: Numan Siddique <nusiddiq@redhat.com>
Tested-by: Numan Siddique <nusiddiq@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
Ben Pfaff
2019-01-10 15:23:45 -08:00
parent 70506167a5
commit 145a7e88bb
9 changed files with 22 additions and 22 deletions

View File

@@ -518,38 +518,38 @@ checks = [
'check': lambda x: trailing_whitespace_or_crlf(x),
'print': lambda: print_warning("Line has trailing whitespace")},
{'regex': '(\.c|\.h)(\.in)?$', 'match_name': None,
{'regex': r'(\.c|\.h)(\.in)?$', 'match_name': None,
'prereq': lambda x: not is_comment_line(x),
'check': lambda x: not if_and_for_whitespace_checks(x),
'print': lambda: print_error("Improper whitespace around control block")},
{'regex': '(\.c|\.h)(\.in)?$', 'match_name': None,
{'regex': r'(\.c|\.h)(\.in)?$', 'match_name': None,
'prereq': lambda x: not is_comment_line(x),
'check': lambda x: not if_and_for_end_with_bracket_check(x),
'print': lambda: print_error("Inappropriate bracing around statement")},
{'regex': '(\.c|\.h)(\.in)?$', 'match_name': None,
{'regex': r'(\.c|\.h)(\.in)?$', 'match_name': None,
'prereq': lambda x: not is_comment_line(x),
'check': lambda x: pointer_whitespace_check(x),
'print':
lambda: print_error("Inappropriate spacing in pointer declaration")},
{'regex': '(\.c|\.h)(\.in)?$', 'match_name': None,
{'regex': r'(\.c|\.h)(\.in)?$', 'match_name': None,
'prereq': lambda x: not is_comment_line(x),
'check': lambda x: trailing_operator(x),
'print':
lambda: print_error("Line has '?' or ':' operator at end of line")},
{'regex': '(\.c|\.h)(\.in)?$', 'match_name': None,
{'regex': r'(\.c|\.h)(\.in)?$', 'match_name': None,
'prereq': lambda x: has_comment(x),
'check': lambda x: has_xxx_mark(x),
'print': lambda: print_warning("Comment with 'xxx' marker")},
{'regex': '(\.c|\.h)(\.in)?$', 'match_name': None,
{'regex': r'(\.c|\.h)(\.in)?$', 'match_name': None,
'prereq': lambda x: has_comment(x),
'check': lambda x: check_comment_spelling(x)},
{'regex': '(\.c|\.h)(\.in)?$', 'match_name': None,
{'regex': r'(\.c|\.h)(\.in)?$', 'match_name': None,
'check': lambda x: empty_return_with_brace(x),
'interim_line': True,
'print':
@@ -584,7 +584,7 @@ std_functions = [
('error', 'Use ovs_error() in place of error()'),
]
checks += [
{'regex': '(\.c|\.h)(\.in)?$',
{'regex': r'(\.c|\.h)(\.in)?$',
'match_name': None,
'prereq': lambda x: not is_comment_line(x),
'check': regex_function_factory(function_name),
@@ -601,11 +601,11 @@ infix_operators = \
[re.escape(op) for op in ['%', '<<', '>>', '<=', '>=', '==', '!=',
'^', '|', '&&', '||', '?:', '=', '+=', '-=', '*=', '/=', '%=',
'&=', '^=', '|=', '<<=', '>>=']] \
+ ['[^<" ]<[^=" ]', '[^->" ]>[^=" ]', '[^ !()/"]\*[^/]', '[^ !&()"]&',
'[^" +(]\+[^"+;]', '[^" -(]-[^"->;]', '[^" <>=!^|+\-*/%&]=[^"=]',
+ ['[^<" ]<[^=" ]', '[^->" ]>[^=" ]', r'[^ !()/"]\*[^/]', '[^ !&()"]&',
r'[^" +(]\+[^"+;]', '[^" -(]-[^"->;]', r'[^" <>=!^|+\-*/%&]=[^"=]',
'[^* ]/[^* ]']
checks += [
{'regex': '(\.c|\.h)(\.in)?$', 'match_name': None,
{'regex': r'(\.c|\.h)(\.in)?$', 'match_name': None,
'prereq': lambda x: not is_comment_line(x),
'check': regex_operator_factory(operator),
'print': lambda: print_warning("Line lacks whitespace around operator")}
@@ -694,7 +694,7 @@ def ovs_checkpatch_parse(text, filename, author=None, committer=None):
current_file = filename if checking_file else ''
previous_file = ''
seppatch = re.compile(r'^---([\w]*| \S+)$')
hunks = re.compile('^(---|\+\+\+) (\S+)')
hunks = re.compile(r'^(---|\+\+\+) (\S+)')
hunk_differences = re.compile(
r'^@@ ([0-9-+]+),([0-9-+]+) ([0-9-+]+),([0-9-+]+) @@')
is_author = re.compile(r'^(Author|From): (.*)$', re.I | re.M | re.S)