From patchwork Mon May 1 20:14:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Conole X-Patchwork-Id: 757307 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 3wGwdb71c8z9sMN for ; Tue, 2 May 2017 06:15:15 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id E6CECC5B; Mon, 1 May 2017 20:14:16 +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 1F090C44 for ; Mon, 1 May 2017 20:14:14 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id CA47B2B9 for ; Mon, 1 May 2017 20:14:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4B5122CBE14; Mon, 1 May 2017 20:14:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4B5122CBE14 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=aconole@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4B5122CBE14 Received: from dhcp-25-97.bos.redhat.com (unknown [10.18.25.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id E93BF5DD71; Mon, 1 May 2017 20:14:12 +0000 (UTC) From: Aaron Conole To: dev@openvswitch.org Date: Mon, 1 May 2017 16:14:04 -0400 Message-Id: <20170501201409.12116-3-aconole@redhat.com> In-Reply-To: <20170501201409.12116-1-aconole@redhat.com> References: <20170501201409.12116-1-aconole@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 01 May 2017 20:14:13 +0000 (UTC) X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD 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 v4 2/7] checkpatch: common print_line 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 With the new framework, print_line can be moved out to the checks framework. Signed-off-by: Aaron Conole --- utilities/checkpatch.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py index b3b833b..30c0a3e 100755 --- a/utilities/checkpatch.py +++ b/utilities/checkpatch.py @@ -200,9 +200,14 @@ def get_file_type_checks(filename): def run_checks(current_file, line, lineno): """Runs the various checks for the particular line. This will take filename into account.""" + print_line = False for check in get_file_type_checks(current_file): if check['check'](line): check['print'](lineno) + print_line = True + + if print_line: + print("\n%s\n" % line) def ovs_checkpatch_parse(text): @@ -258,7 +263,6 @@ def ovs_checkpatch_parse(text): m = is_co_author.match(line) co_authors.append(m.group(3)) elif parse == 2: - print_line = False newfile = hunks.match(line) if newfile: current_file = newfile.group(2) @@ -283,26 +287,19 @@ def ovs_checkpatch_parse(text): continue if (not current_file.endswith('.mk') and not leading_whitespace_is_spaces(cmp_line)): - print_line = True print_warning("Line has non-spaces leading whitespace", lineno) run_checks(current_file, cmp_line, lineno) if trailing_whitespace_or_crlf(cmp_line): - print_line = True print_warning("Line has trailing whitespace", lineno) if not if_and_for_whitespace_checks(cmp_line): - print_line = True print_error("Improper whitespace around control block", lineno) 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: return -1 return 0