From patchwork Wed Jan 24 02:31:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Pettit X-Patchwork-Id: 865132 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 3zR8MW4FBmz9s74 for ; Wed, 24 Jan 2018 13:32:22 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id BFD9EF31; Wed, 24 Jan 2018 02:32: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 9FDBCFAF for ; Wed, 24 Jan 2018 02:32:18 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 11981284 for ; Wed, 24 Jan 2018 02:32:17 +0000 (UTC) X-Originating-IP: 98.234.50.139 Received: from localhost.localdomain (unknown [98.234.50.139]) (Authenticated sender: jpettit@ovn.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 5A60D1720A4 for ; Wed, 24 Jan 2018 03:32:15 +0100 (CET) From: Justin Pettit To: dev@openvswitch.org Date: Tue, 23 Jan 2018 18:31:29 -0800 Message-Id: <1516761089-90086-1-git-send-email-jpettit@ovn.org> X-Mailer: git-send-email 2.7.4 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] checkpatch.py: Add check for "xxx" in comments. 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 "xxx" is often used to indicate items that the developer wanted to look at again before committing. Flag those as a warning. Signed-off-by: Justin Pettit Acked-by: Aaron Conole --- utilities/checkpatch.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py index 33feb6bddca1..42777e6fcb15 100755 --- a/utilities/checkpatch.py +++ b/utilities/checkpatch.py @@ -1,5 +1,6 @@ #!/usr/bin/env python # Copyright (c) 2016, 2017 Red Hat, Inc. +# Copyright (c) 2018 Nicira, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -95,9 +96,11 @@ __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_has_comment = re.compile(r'.*(/\*|\*\s)') __regex_trailing_operator = re.compile(r'^[^ ]* [^ ]*[?:]$') __regex_conditional_else_bracing = re.compile(r'^\s*else\s*{?$') __regex_conditional_else_bracing2 = re.compile(r'^\s*}\selse\s*$') +__regex_has_xxx_mark = re.compile(r'.*xxx.*', re.IGNORECASE) skip_leading_whitespace_check = False skip_trailing_whitespace_check = False @@ -213,11 +216,19 @@ def is_comment_line(line): """Returns TRUE if the current line is part of a block comment.""" return __regex_is_comment_line.match(line) is not None +def has_comment(line): + """Returns TRUE if the current line contains a comment or is part of + a block comment.""" + return __regex_has_comment.match(line) is not None def trailing_operator(line): """Returns TRUE if the current line ends with an operatorsuch as ? or :""" return __regex_trailing_operator.match(line) is not None +def has_xxx_mark(line): + """Returns TRUE if the current line contains 'xxx'.""" + return __regex_has_xxx_mark.match(line) is not None + checks = [ {'regex': None, @@ -257,6 +268,11 @@ checks = [ 'check': lambda x: trailing_operator(x), 'print': lambda: print_error("Line has '?' or ':' operator at end of line")}, + + {'regex': '(\.c|\.h)(\.in)?$', 'match_name': None, + 'prereq': lambda x: has_comment(x), + 'check': lambda x: has_xxx_mark(x), + 'print': lambda: print_warning("Comment with 'xxx' marker")}, ]