From patchwork Wed Aug 9 20:37:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Stringer X-Patchwork-Id: 799946 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xSNRJ3Rc9z9sN5 for ; Thu, 10 Aug 2017 06:39:24 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 76D44C94; Wed, 9 Aug 2017 20:38:06 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 391DAC96 for ; Wed, 9 Aug 2017 20:38:03 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 05B431F2 for ; Wed, 9 Aug 2017 20:38:02 +0000 (UTC) X-Originating-IP: 208.91.1.34 Received: from carno.eng.vmware.com (unknown [208.91.1.34]) (Authenticated sender: joe@ovn.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 3D4C3A80CE for ; Wed, 9 Aug 2017 22:38:00 +0200 (CEST) From: Joe Stringer To: dev@openvswitch.org Date: Wed, 9 Aug 2017 13:37:52 -0700 Message-Id: <20170809203752.16886-3-joe@ovn.org> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170809203752.16886-1-joe@ovn.org> References: <20170809203752.16886-1-joe@ovn.org> Subject: [ovs-dev] [PATCH 3/3] checkpatch: Check for trailing operators. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org The style guide states that lines should not end with '?' or ':'. Check for this and report an error. Signed-off-by: Joe Stringer Acked-by: Ben Pfaff --- v2: Restrict to '?' and ':'. Make sure that goto tags aren't flagged. --- utilities/checkpatch.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py index 1bb256ccd4d6..e553076d7d1c 100755 --- a/utilities/checkpatch.py +++ b/utilities/checkpatch.py @@ -94,6 +94,7 @@ __regex_ends_with_bracket = \ re.compile(r'[^\s]\) {(\s+/\*[\s\Sa-zA-Z0-9\.,\?\*/+-]*)?$') __regex_ptr_declaration_missing_whitespace = re.compile(r'[a-zA-Z0-9]\*[^*]') __regex_is_comment_line = re.compile(r'^\s*(/\*|\*\s)') +__regex_trailing_operator = re.compile(r'^[^ ]* [^ ]*[?:]$') skip_leading_whitespace_check = False skip_trailing_whitespace_check = False @@ -206,6 +207,11 @@ def is_comment_line(line): return __regex_is_comment_line.match(line) is not None +def trailing_operator(line): + """Returns TRUE if the current line ends with an operator, eg &&""" + return __regex_trailing_operator.match(line) is not None + + checks = [ {'regex': None, 'match_name': @@ -237,7 +243,13 @@ checks = [ 'prereq': lambda x: not is_comment_line(x), 'check': lambda x: pointer_whitespace_check(x), 'print': - lambda: print_error("Inappropriate spacing in pointer declaration")} + lambda: print_error("Inappropriate spacing in pointer declaration")}, + + {'regex': '(\.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")}, ]