diff options
author | Ilya Maximets <i.maximets@ovn.org> | 2022-09-14 13:06:38 +0200 |
---|---|---|
committer | Ilya Maximets <i.maximets@ovn.org> | 2022-09-15 14:18:25 +0200 |
commit | 950aee1f7e1113a030b5e62ed036608480118b9d (patch) | |
tree | 5d2aecab7a002edc00bc2e53a492be73c1bb4efe | |
parent | b1550dddeba968924e2bd79cc507d16e99aa7a13 (diff) | |
download | openvswitch-950aee1f7e1113a030b5e62ed036608480118b9d.tar.gz |
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>
-rwxr-xr-x | tests/checkpatch.at | 27 | ||||
-rwxr-xr-x | utilities/checkpatch.py | 11 |
2 files changed, 38 insertions, 0 deletions
diff --git a/tests/checkpatch.at b/tests/checkpatch.at index 9ab87410e..fdcdb846e 100755 --- a/tests/checkpatch.at +++ b/tests/checkpatch.at @@ -366,6 +366,33 @@ try_checkpatch \ AT_CLEANUP + +AT_SETUP([checkpatch - check egrep / fgrep]) +try_checkpatch \ + "COMMON_PATCH_HEADER([tests/something.at]) + +C_H_E_C_K([[ovs-vsctl show | grep -E 'my-port.*[[0-9]]$' | grep -F 'port']]) + " + +try_checkpatch \ + "COMMON_PATCH_HEADER([tests/something.at]) + +C_H_E_C_K([[ovs-vsctl show | egrep 'my-port.*[[0-9]]$']]) + " \ + "ERROR: grep -E/-F should be used instead of egrep/fgrep + #8 FILE: tests/something.at:1: + C_H_E_C_K([[ovs-vsctl show | egrep 'my-port.*[[0-9]]$']]) +" + +try_checkpatch \ + "COMMON_PATCH_HEADER([tests/something.at]) + +C_H_E_C_K([[ovs-vsctl show | fgrep 'my-port.*[[0-9]]$']]) + " \ + "ERROR: grep -E/-F should be used instead of egrep/fgrep + #8 FILE: tests/something.at:1: + C_H_E_C_K([[ovs-vsctl show | fgrep 'my-port.*[[0-9]]$']]) +" +AT_CLEANUP + + AT_SETUP([checkpatch - whitespace around cast]) try_checkpatch \ "COMMON_PATCH_HEADER diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py index 887928404..0d30b71b5 100755 --- a/utilities/checkpatch.py +++ b/utilities/checkpatch.py @@ -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")}, ] |