From patchwork Fri Jul 14 10:57:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 788329 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 3x88nd5Pd1z9s78 for ; Fri, 14 Jul 2017 20:59:01 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 884D0B50; Fri, 14 Jul 2017 10:57:45 +0000 (UTC) X-Original-To: ovs-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 B66F3ABB for ; Fri, 14 Jul 2017 10:57:43 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 3AA0ACE for ; Fri, 14 Jul 2017 10:57:43 +0000 (UTC) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OT200BP7UG4P310@mailout1.w1.samsung.com> for ovs-dev@openvswitch.org; Fri, 14 Jul 2017 11:57:40 +0100 (BST) Received: from eusmges2.samsung.com (unknown [203.254.199.241]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170714105739eucas1p13cb843db46ea5df263a924a5d99b9975~RLTXJhLOm2955229552eucas1p1X; Fri, 14 Jul 2017 10:57:39 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2.samsung.com (EUCPMTA) with SMTP id 5B.DE.04459.3A3A8695; Fri, 14 Jul 2017 11:57:39 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170714105739eucas1p1e6dfd94cd3ff9fae0cfa5aaff006dd08~RLTWcUzIL0468004680eucas1p1U; Fri, 14 Jul 2017 10:57:39 +0000 (GMT) X-AuditID: cbfec7f1-f796e6d00000116b-da-5968a3a36455 Received: from eusync2.samsung.com ( [203.254.199.212]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 83.98.17452.3A3A8695; Fri, 14 Jul 2017 11:57:39 +0100 (BST) Received: from imaximets.rnd.samsung.ru ([106.109.129.180]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OT2002XQUFQ3220@eusync2.samsung.com>; Fri, 14 Jul 2017 11:57:39 +0100 (BST) From: Ilya Maximets To: ovs-dev@openvswitch.org, Ben Pfaff Date: Fri, 14 Jul 2017 13:57:22 +0300 Message-id: <1500029844-846-3-git-send-email-i.maximets@samsung.com> X-Mailer: git-send-email 2.7.4 In-reply-to: <1500029844-846-1-git-send-email-i.maximets@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrMIsWRmVeSWpSXmKPExsWy7djP87qLF2dEGjzbo2nxanIDo8W0z7fZ La60/2S3mPvpOaMDi8ezm/8ZPZ5f62Hx6NuyijGAOYrLJiU1J7MstUjfLoErY9HC1ywFu8Qr WpvnMjYwThPsYuTkkBAwkZi54h0zhC0mceHeerYuRi4OIYGljBIre5ayQzifGSWuvG1ggulY 828iM0RiGaPEtF0vWCGcZiaJ5uapYLPYBHQkTq0+wghiiwB1LJv6jQ3EZhYIltix/hiYLSzg LzGl4z3YVBYBVYl9936CxXkFXCRO753JCLFNTuLmuU6wmZwCrhKHJs1mAVkmIXCCTeLf591A DRxAjqzEpg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WpBbB9DFx cEo1MNrGV9wUdxTwYjkva21rKfJrydTFurvN4/+y71Cz36X7TabSx2BXsGDCT/cfr1cGT7cu Fcvf1CxWuvPiUub3zT8dgl7/sFjHueXzLa3V6SFa3BvLdRY5+Hv8OcX+7rqA2NUUBmWdu983 Bju/ZLaXfX7k9u3FummbgtrWlzMHGrY5/buwsH3bMSWW4oxEQy3mouJEAJ2jIw9kAgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170714105739eucas1p1e6dfd94cd3ff9fae0cfa5aaff006dd08 X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?SWx5YSBNYXhpbWV0cxtTUlItVmlydHVhbGl6YXRpb24gTGFi?= =?UTF-8?B?G+yCvOyEseyghOyekBtMZWFkaW5nIEVuZ2luZWVy?= X-Global-Sender: =?UTF-8?B?SWx5YSBNYXhpbWV0cxtTUlItVmlydHVhbGl6YXRpb24gTGFi?= =?UTF-8?B?G1NhbXN1bmcgRWxlY3Ryb25pY3MbTGVhZGluZyBFbmdpbmVlcg==?= X-Sender-Code: =?UTF-8?B?QzEwG0NJU0hRG0MxMEdEMDFHRDAxMDE1NA==?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170714105739eucas1p1e6dfd94cd3ff9fae0cfa5aaff006dd08 X-RootMTR: 20170714105739eucas1p1e6dfd94cd3ff9fae0cfa5aaff006dd08 References: <1500029844-846-1-git-send-email-i.maximets@samsung.com> 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 Cc: Ilya Maximets , Heetae Ahn Subject: [ovs-dev] [PATCH 2/4] checkpatch: Print results while checking HEAD and stdin. 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 Currently, result status printed only for patch files. It'll be nice to have results for other checking types. Signed-off-by: Ilya Maximets Acked-by: Aaron Conole --- utilities/checkpatch.py | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py index fe266ac..4a92890 100755 --- a/utilities/checkpatch.py +++ b/utilities/checkpatch.py @@ -63,6 +63,13 @@ def print_warning(message): __warnings = __warnings + 1 +def reset_counters(): + global __errors, __warnings + + __errors = 0 + __warnings = 0 + + # These are keywords whose names are normally followed by a space and # something in parentheses (usually an expression) then a left curly brace. # @@ -323,6 +330,8 @@ def ovs_checkpatch_parse(text, filename): is_gerrit_change_id = re.compile(r'(\s*(change-id: )(.*))$', re.I | re.M | re.S) + reset_counters() + for line in text.split('\n'): if current_file != previous_file: previous_file = current_file @@ -414,8 +423,16 @@ Check options: % sys.argv[0]) +def ovs_checkpatch_print_result(result): + global __warnings, __errors, total_line + if result < 0: + print("Lines checked: %d, Warnings: %d, Errors: %d\n" % + (total_line, __warnings, __errors)) + else: + print("Lines checked: %d, no obvious problems found\n" % (total_line)) + + def ovs_checkpatch_file(filename): - global __warnings, __errors, checking_file, total_line try: mail = email.message_from_file(open(filename, 'r')) except: @@ -426,11 +443,7 @@ def ovs_checkpatch_file(filename): if part.get_content_maintype() == 'multipart': continue result = ovs_checkpatch_parse(part.get_payload(decode=False), filename) - if result < 0: - print("Lines checked: %d, Warnings: %d, Errors: %d" % - (total_line, __warnings, __errors)) - else: - print("Lines checked: %d, no obvious problems found" % (total_line)) + ovs_checkpatch_print_result(result) return result @@ -494,7 +507,9 @@ if __name__ == '__main__': f.close() print('== Checking %s ==' % revision) - if ovs_checkpatch_parse(patch, revision): + result = ovs_checkpatch_parse(patch, revision) + ovs_checkpatch_print_result(result) + if result: status = -1 sys.exit(status) @@ -504,5 +519,7 @@ if __name__ == '__main__': if sys.stdin.isatty(): usage() sys.exit(-1) - sys.exit(ovs_checkpatch_parse(sys.stdin.read(), '-')) + result = ovs_checkpatch_parse(sys.stdin.read(), '-') + ovs_checkpatch_print_result(result) + sys.exit(result) sys.exit(ovs_checkpatch_file(filename))