Received: by 10.223.164.202 with SMTP id h10csp2336632wrb; Thu, 16 Nov 2017 13:27:07 -0800 (PST) X-Google-Smtp-Source: AGs4zMbxZzc+uoy74+GwxV6k1hVlbaYLrnVywMF40o/CuMx2rAcNs9wAy62Wd2iDcKOnp0RSj3DN X-Received: by 10.84.240.73 with SMTP id h9mr3006965plt.388.1510867627821; Thu, 16 Nov 2017 13:27:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510867627; cv=none; d=google.com; s=arc-20160816; b=trYd2jYfpsJaB24XNphXQ5JXFgi05ijxIpq14scPTkh8LjggdiyEhFwLCj0okr+sPt RbquhDQpvIXUzT8WSglYedL7iQjcXdpWkYFuGLwSBJ76ydzLiWMxlDRXs6OLOqQcdOtv dahDHndm8MwEll1TSPFh8WesycLW1mOib4A1G1GquMltl2iFCkf7/WWSUR72imV/mKfJ JNTSKFzlLkR0HhEB30SacLDEK1iLX0Ff2KEZGuQAkW8Em4bNQSZKe5FZSu8DB6Lqeklu yR8DrW/ZvvoSk6PL0HqERJdXpHDWsAK72Qhxu4u8fOeAwvQJ9FOALeINHkVkaz0mPbDP Wm2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:references :in-reply-to:mime-version:message-id:date:subject:cc:to:from :arc-authentication-results; bh=EyG+pdrXrxq/gsaydLZ+BTzQFmR8hz2plBohW5607/c=; b=sjDJMJzG6bK/OfZDd67hI6VqW42tR0zPD/2tu2rWOCakpH0AXPMKU3Zf3qO/4raUXp +07DLi+D3Q23juyoVS7Jr5bZlImGDKtQJxfrf2JhlV6XGrHtpUGw6FycyDlAsQC8GmBZ k/X1oAEMmY+ufmmkcWE7WLxYlKfctHMo6NthgvYreqQ2eiXCIy6vmm5loSw3kaso9kKk 7wbZL2/rJJNj5kSUXv0zxsFbV9ok6Q7JEv7kOkzPnBrqeN8kXcz+ltql+YvTKZqjPEjX NeO6X/pZSP4FE6kTEn3704N5RKYqBp9S7BuPeZLYZlXfLdniZDfuTh/q+/y+PRtZwEGI htAw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bd7si1457658plb.362.2017.11.16.13.26.54; Thu, 16 Nov 2017 13:27:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965480AbdKPREL (ORCPT + 92 others); Thu, 16 Nov 2017 12:04:11 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:50804 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936037AbdKPRC1 (ORCPT ); Thu, 16 Nov 2017 12:02:27 -0500 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id vAGH2Nov000546 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Nov 2017 17:02:23 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id vAGH2MEc008437 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Nov 2017 17:02:23 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id vAGH2MwY017868; Thu, 16 Nov 2017 17:02:22 GMT Received: from abi.no.oracle.com (/10.172.144.123) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 16 Nov 2017 09:02:21 -0800 From: Knut Omang To: linux-kernel@vger.kernel.org Cc: Knut Omang , Andy Whitcroft , Joe Perches Subject: [PATCH 1/7] checkpatch: Implement new --ignore-cfg parameter Date: Thu, 16 Nov 2017 18:01:41 +0100 Message-Id: <280c16fb1b8a645f0c62cea03f440fd0661af898.1510840787.git-series.knut.omang@oracle.com> X-Mailer: git-send-email 2.13.6 MIME-Version: 1.0 In-Reply-To: References: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Source-IP: aserv0021.oracle.com [141.146.126.233] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This parameter is intended to be used in a subsequent commit to kbuild to allow a convenient way to run checkpatch from make. The parameter --ignore-cfg causes checkpatch.pl to look for the file given as parameter, either directly from where checkpatch is executed, or in the directory where the file to check is located. With this parameter checkpatch is now limited to run on a single file for each invocation. This should not be a problem for the Makefile scenario as it is the standard behaviour anyway. This file accepts the following syntax: # comments line_len except checkpatch_type [files ...] pervasive checkpatch_type1 [checkpatch_type2 ...] The line_len command defines the upper bound of characters per line tolerated in this directory. The except command takes a checkpatch type such as for example MACRO_ARG_REUSE, and a set of files that should not be subject to this particular check type. The pervasive command disables the listed types of checks for all the files in the directory. The except and pervasive command can be used cumulatively to add more exceptions. By accepting comments and multiple lines of commands, the idea is that the maintainer or someone else with good knowledge of the code can maintain a file per directory and group the different commands into commented sections that can serve both as documentation of the current checkpatch status, a way to define the line of tolerance (and gradually tighten it as fixes comes in) and as documentation of TODOs and dont's if there are well justified exceptions. Signed-off-by: Knut Omang Acked-by: Håkon Bugge Acked-by: Åsmund Østvold --- scripts/checkpatch.pl | 57 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 8b80bac..834a1d8 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -48,6 +48,7 @@ my %ignore_type = (); my @ignore = (); my $help = 0; my $configuration_file = ".checkpatch.conf"; +my $ignore_cfg_file; my $max_line_length = 80; my $ignore_perl_version = 0; my $minimum_perl_version = 5.10.0; @@ -90,6 +91,9 @@ Options: --list-types list the possible message types --types TYPE(,TYPE2...) show only these comma separated message types --ignore TYPE(,TYPE2...) ignore various comma separated message types + --ignore-cfg FILE parse this file for a detailed file specific ignore list, + silently exit without checking if an ignore config file + is not found. --show-types show the specific message type in the output --max-line-length=n set the maximum line length, if exceeded, warn --min-conf-desc-length=n set the min description length, if shorter, warn @@ -201,6 +205,7 @@ GetOptions( 'terse!' => \$terse, 'showfile!' => \$showfile, 'f|file!' => \$file, + 'ignore-cfg=s' => \$ignore_cfg_file, 'g|git!' => \$git, 'subjective!' => \$check, 'strict!' => \$check, @@ -233,6 +238,9 @@ help(0) if ($help); list_types(0) if ($list_types); +# Enforce --strict if used with a ignore configuration file: +$check = 1 if defined($ignore_cfg_file); + $fix = 1 if ($fix_inplace); $check_orig = $check; @@ -291,6 +299,7 @@ sub hash_show_words { } } +parse_ignore_cfg_file(@ARGV) || exit(0); hash_save_array_words(\%ignore_type, \@ignore); hash_save_array_words(\%use_type, \@use); @@ -2160,6 +2169,54 @@ sub pos_last_openparen { return length(expand_tabs(substr($line, 0, $last_openparen))) + 1; } +# Checkpatch suppression list configuration file support +# +# See Documentation/dev-tools/run-checkpatch.rst +# +sub parse_ignore_cfg_file { + defined($ignore_cfg_file) || return 1; + my $path = shift(@_); + my $filename = basename($path); + my $dir = dirname($path); + my %IgnoreCfgKeywords = ( + 'except' => sub { my $type = shift(@_); + grep( /^$filename$/, @_ ) && push(@ignore, $type); + }, + 'pervasive' => sub { push(@ignore, @_); }, + 'line_len' => sub { $max_line_length = shift(@_); } + ); + my $ignfile; + + ( -f $ignore_cfg_file ) || ( $ignore_cfg_file = "$dir/$ignore_cfg_file" ); + ( ! -f $ignore_cfg_file ) && return 0; + open($ignfile, '<', "$ignore_cfg_file") || return 0; + + ($#_ >= 0) && + die "$P: The --ignore-cfg option is only supported with one source file at a time!\n"; + + while (<$ignfile>) { + my $line = $_; + + $line =~ s/\s*\n?$//g; + $line =~ s/^\s*//g; + $line =~ s/\s+/ /g; + $line =~ s/#.*//g; + $line =~ m/^\s*$/ && next; + + my @words = split(" ", $line); + my $kw = shift(@words); + defined($kw) or next; + my $cmd = $IgnoreCfgKeywords{$kw}; + if ( !defined($cmd) ) { + print "$line\n"; + warn("Unknown keyword \"$kw\" in file \"$ignore_cfg_file\"\n"); + next; + } + &$cmd(@words); + } + return 1; +} + sub process { my $filename = shift; -- git-series 0.9.1 From 1584246136620373906@xxx Thu Nov 16 17:54:11 +0000 2017 X-GM-THRID: 1584246136620373906 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread