Received: by 10.223.164.202 with SMTP id h10csp2326754wrb; Thu, 16 Nov 2017 13:15:05 -0800 (PST) X-Google-Smtp-Source: AGs4zMbKVEu1BLIeBSXmZOGKgYo7Qb22AKfXKBk0OlEpYNpUgY1Vw94B3GT4TVdVnPgrqdtY7gZc X-Received: by 10.84.240.6 with SMTP id y6mr2844300plk.301.1510866905352; Thu, 16 Nov 2017 13:15:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510866905; cv=none; d=google.com; s=arc-20160816; b=nNroxjk7xYFA3Gvc47PSufJfDii382A+DOFfS/xEripFIp4BpZ15ugdebSdZnsjgqU H1jE00moQXFMVsbZbP3Dp1+jLEtfbcvp/Z9wyvbzWCdb5GbM33uIKKrMP1T4eirkXWP/ Q+QuKPUer3ueBFjtSw4WUnz1JsJpRV2vWk+CE8iwdTeYtJWS4c9cdQhdI7D57rEDGgkB qmqXF+Mcgmn+iCDWpN0wXvYsPqkXrUBsYmum+Gl+XY55dPwfk0HTG12U6z03RpsDmvhj 9Y8x5OSN+C+/u6ctpFpNxKU0laIlXgXKcKABDU3hD5+kwUf447NUMmIdJQHTk66w2dkg 7jlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=WUpWvfBrq7l0LGyQnSre0yn9LyOLzGOPSY1yV7LPLhQ=; b=clyYLFV8yHEUgvwW4hcNj5jAs+XxYJPQOf+POBkoHNyCC/fGdbj1nOdDr3NT6JDtwq OXHWSp8Ivf1sfLkLpQ1tjgM+C20ob28QxAZTxI+QBZkc1iDeITIr8DOqIu00mjDlyz11 /R/XiZImVV/IJNb2JFDCgLs8sGKlpqz50ySwDLU3qC27InDRi+xTZZ/vbbNCL0DhedWF uf3soX2uVOq0qkPLSWhv28DCw4ikzh40pnGbJ0oGNF/AHO2E0NVDbGq85jbZDleGb+Ho cf+urKzpIpROznKWEqyvYPvj1JEjYuvW4c/ERq0cPrDl/vs439yjYvmPOiypQKh67rHC eWLw== 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 e33si1489453pld.533.2017.11.16.13.14.52; Thu, 16 Nov 2017 13:15:05 -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 S965418AbdKPRDY (ORCPT + 92 others); Thu, 16 Nov 2017 12:03:24 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:50963 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936124AbdKPRCk (ORCPT ); Thu, 16 Nov 2017 12:02:40 -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 vAGH2alC000865 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Nov 2017 17:02:36 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 vAGH2ZA4009005 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Nov 2017 17:02:36 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 vAGH2ZS4017992; Thu, 16 Nov 2017 17:02:35 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:35 -0800 From: Knut Omang To: linux-kernel@vger.kernel.org Cc: Knut Omang , Andy Whitcroft , Joe Perches Subject: [PATCH 6/7] checkpatch: Make --ignore-cfg look recursively for the file Date: Thu, 16 Nov 2017 18:01:46 +0100 Message-Id: X-Mailer: git-send-email 2.13.6 In-Reply-To: References: 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 The initial version of the logic for --ignore-cfg supported looking for the file in the current directory, and if not found, look in the directory of the source file. With this change, in the case of a file name with no directory specification, and for an in-kernel file, checkpatch will iterate upwards in the directories above, looking for the same file until either hitting the top of the tree or finding a match. This should make the P={1,2} make target more useful for maintainers, as a start of functionality for checkpatch checking that can be globally enabled for a subsystem. Signed-off-by: Knut Omang --- scripts/checkpatch.pl | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index c17178e..a276eca 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2186,15 +2186,47 @@ 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; + +# Usage: find_ignore_cfg_file(filename,ignorefilename) +# If filename contains a directory, use it directly with no further attempts, +# If no directory is specified, whether relative or absolute, +# look for 'filename' in the following order until a match is found: +# 1) current dir, +# 2) the directory of the source file +# 3) if an in-source source-file (same source tree as this script) +# look in directories above for the first match. +# +sub find_ignore_cfg_file { my $path = shift(@_); + my $ipath = shift(@_); + my $ifile = basename($ipath); my $filename = basename($path); my $dir = dirname($path); + my $root = dirname($D); + ( -f $ipath ) && return ($filename, $ipath); + ( $ipath =~ m/\// ) && return ($filename,""); + + do { + $ipath = "$dir/$ifile"; + #print "*** Trying $ipath ***\n"; + ( -f $ipath ) && return ($filename, $ipath); + $dir = dirname($dir); + } while ( $dir =~ m/^$root/ && ! -f $ifile ); + return ($filename,""); +} + + +sub parse_ignore_cfg_file { + my $path = shift(@_); + my $filename; # The file to check + my $ifile; # The ignore file name + my $ignfile; # The ignore file handle + defined($ignore_cfg_file) || return 1; my %IgnoreCfgKeywords = ( 'except' => sub { my $type = shift(@_); grep( /^$filename$/, @_ ) && push(@ignore, $type); @@ -2202,11 +2234,11 @@ sub parse_ignore_cfg_file { '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; + ($filename, $ifile) = find_ignore_cfg_file($path, $ignore_cfg_file); + ( $ifile eq "" ) && return 0; + open($ignfile, '<', "$ifile") || return 0; + #print "*** Found $ifile ***\n"; ($#_ >= 0) && die "$P: The --ignore-cfg option is only supported with one source file at a time!\n"; -- git-series 0.9.1 From 1584189704233396528@xxx Thu Nov 16 02:57:13 +0000 2017 X-GM-THRID: 1583929063651093838 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread