mirror of
https://github.com/openvswitch/ovs
synced 2025-08-30 22:05:19 +00:00
checkpatch: Escape range operators inside regex.
' -(' matches a single character in the range between ' ' (index 32)
and '(' (index 40). This leads to the false positive:
WARNING: Line lacks whitespace around operator
#445 FILE: ovsdb/monitor.c:573:
if (--mcs->n_refs == 0) {
Need to escape '-' to have a right behaviour.
This patch additionally escapes all other '-' chars in the similar
regexes and makes them be one per line to ease the review in case of
future changes.
Basic unit tests added.
CC: Joe Stringer <joe@ovn.org>
Fixes: 0d7b16daea
("checkpatch: Check for infix operator whitespace.")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
@@ -612,9 +612,14 @@ infix_operators = \
|
||||
[re.escape(op) for op in ['%', '<<', '>>', '<=', '>=', '==', '!=',
|
||||
'^', '|', '&&', '||', '?:', '=', '+=', '-=', '*=', '/=', '%=',
|
||||
'&=', '^=', '|=', '<<=', '>>=']] \
|
||||
+ ['[^<" ]<[^=" ]', '[^->" ]>[^=" ]', r'[^ !()/"]\*[^/]', '[^ !&()"]&',
|
||||
r'[^" +(]\+[^"+;]', '[^" -(]-[^"->;]', r'[^" <>=!^|+\-*/%&]=[^"=]',
|
||||
'[^* ]/[^* ]']
|
||||
+ [r'[^<" ]<[^=" ]',
|
||||
r'[^\->" ]>[^=" ]',
|
||||
r'[^ !()/"]\*[^/]',
|
||||
r'[^ !&()"]&',
|
||||
r'[^" +(]\+[^"+;]',
|
||||
r'[^" \-(]\-[^"\->;]',
|
||||
r'[^" <>=!^|+\-*/%&]=[^"=]',
|
||||
r'[^* ]/[^* ]']
|
||||
checks += [
|
||||
{'regex': r'(\.c|\.h)(\.in)?$', 'match_name': None,
|
||||
'prereq': lambda x: not is_comment_line(x),
|
||||
|
Reference in New Issue
Block a user