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

checkpatch: Add check for egrep/fgrep.

GNU grep 3.8 started complaining about use of obsolete egrep/fgrep:

  egrep: warning: egrep is obsolescent; using grep -E

This breaks tests on such systems.  All the instances was cleaned up
from the testsuite, but the checkpatch check is needed to catch issues
in new patches.

Acked-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
This commit is contained in:
Ilya Maximets
2022-09-14 13:06:38 +02:00
parent b1550dddeb
commit 950aee1f7e
2 changed files with 38 additions and 0 deletions

View File

@@ -182,6 +182,7 @@ __regex_empty_return = re.compile(r'\s*return;')
__regex_if_macros = re.compile(r'^ +(%s) \([\S]([\s\S]+[\S])*\) { +\\' %
__parenthesized_constructs)
__regex_nonascii_characters = re.compile("[^\u0000-\u007f]")
__regex_efgrep = re.compile(r'.*[ef]grep.*$')
skip_leading_whitespace_check = False
skip_trailing_whitespace_check = False
@@ -341,6 +342,11 @@ def has_xxx_mark(line):
return __regex_has_xxx_mark.match(line) is not None
def has_efgrep(line):
"""Returns TRUE if the current line contains 'egrep' or 'fgrep'."""
return __regex_efgrep.match(line) is not None
def filter_comments(current_line, keep=False):
"""remove all of the c-style comments in a line"""
STATE_NORMAL = 0
@@ -608,6 +614,11 @@ checks = [
'print':
lambda: print_warning("Empty return followed by brace, consider omitting")
},
{'regex': r'(\.at|\.sh)$', 'match_name': None,
'check': lambda x: has_efgrep(x),
'print':
lambda: print_error("grep -E/-F should be used instead of egrep/fgrep")},
]