From patchwork Wed Sep 14 15:27:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1677949 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MSPNr5RCXz1ynm for ; Thu, 15 Sep 2022 01:28:12 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 1491E402EC; Wed, 14 Sep 2022 15:28:10 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 1491E402EC X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mUUWPrnneclJ; Wed, 14 Sep 2022 15:28:08 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id 9836A400AA; Wed, 14 Sep 2022 15:28:07 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 9836A400AA Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 433E5C0033; Wed, 14 Sep 2022 15:28:07 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id E87E1C002D for ; Wed, 14 Sep 2022 15:28:04 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id A8DCA40C63 for ; Wed, 14 Sep 2022 15:28:04 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org A8DCA40C63 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ApJgTi8ZsKZ7 for ; Wed, 14 Sep 2022 15:28:02 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 1323A40C11 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by smtp2.osuosl.org (Postfix) with ESMTPS id 1323A40C11 for ; Wed, 14 Sep 2022 15:28:00 +0000 (UTC) Received: (Authenticated sender: i.maximets@ovn.org) by mail.gandi.net (Postfix) with ESMTPSA id 37922E0009; Wed, 14 Sep 2022 15:27:51 +0000 (UTC) From: Ilya Maximets To: ovs-dev@openvswitch.org Date: Wed, 14 Sep 2022 17:27:49 +0200 Message-Id: <20220914152749.539677-1-i.maximets@ovn.org> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Cc: Andreas Stieger , Ilya Maximets Subject: [ovs-dev] [PATCH] checkpatch: Add check for egrep/fgrep. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" 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. Signed-off-by: Ilya Maximets Acked-by: Aaron Conole --- tests/checkpatch.at | 27 +++++++++++++++++++++++++++ utilities/checkpatch.py | 11 +++++++++++ 2 files changed, 38 insertions(+) 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")}, ]