From patchwork Wed Mar 8 17:54:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Stringer X-Patchwork-Id: 736673 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3vdh402zB5z9sN9 for ; Thu, 9 Mar 2017 04:54:23 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id F3A4BB76; Wed, 8 Mar 2017 17:54:19 +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 D6D32A88 for ; Wed, 8 Mar 2017 17:54:18 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 3638710C for ; Wed, 8 Mar 2017 17:54:18 +0000 (UTC) Received: from mfilter20-d.gandi.net (mfilter20-d.gandi.net [217.70.178.148]) by relay5-d.mail.gandi.net (Postfix) with ESMTP id B10DB41C0A8 for ; Wed, 8 Mar 2017 18:54:16 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter20-d.gandi.net Received: from relay5-d.mail.gandi.net ([IPv6:::ffff:217.70.183.197]) by mfilter20-d.gandi.net (mfilter20-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id 5Ong_4V1Ycuw for ; Wed, 8 Mar 2017 18:54:15 +0100 (CET) X-Originating-IP: 208.91.1.34 Received: from carno.eng.vmware.com (unknown [208.91.1.34]) (Authenticated sender: joe@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id D3D2741C084 for ; Wed, 8 Mar 2017 18:54:14 +0100 (CET) From: Joe Stringer To: dev@openvswitch.org Date: Wed, 8 Mar 2017 09:54:06 -0800 Message-Id: <20170308175407.11142-1-joe@ovn.org> X-Mailer: git-send-email 2.11.1 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 1/2] checkpatch: Check for pointer whitespace. 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 Signed-off-by: Joe Stringer Acked-by: Russell Bryant --- utilities/checkpatch.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py index 26eb5c32b9bc..e795646de4a8 100755 --- a/utilities/checkpatch.py +++ b/utilities/checkpatch.py @@ -68,6 +68,7 @@ __regex_is_for_if_single_line_bracket = \ re.compile(r'^ +(if|for|while) \(.*\)') __regex_ends_with_bracket = \ re.compile(r'[^\s]\) {(\s+/\*[\s\Sa-zA-Z0-9\.,\?\*/+-]*)?$') +__regex_pointer_declaration_missing_whitespace = re.compile(r'[a-zA-Z0-9]\*') skip_leading_whitespace_check = False skip_trailing_whitespace_check = False @@ -157,6 +158,15 @@ def if_and_for_end_with_bracket_check(line): return True +def pointer_whitespace_check(line): + """Return TRUE if there is not an asterisk between a pointer name and the + asterisk that denotes this is a apionter type, ie: 'struct foo*'""" + + if __regex_pointer_declaration_missing_whitespace.search(line) is not None: + return True + return False + + def ovs_checkpatch_parse(text): global print_file_name lineno = 0 @@ -257,6 +267,10 @@ def ovs_checkpatch_parse(text): if not if_and_for_end_with_bracket_check(cmp_line): print_line = True print_error("Inappropriate bracing around statement", lineno) + if pointer_whitespace_check(cmp_line): + print_line = True + print_error("Inappropriate spacing in pointer declaration", + lineno) if print_line: print("\n%s\n" % line) if __errors or __warnings: