From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754232AbbCaT4i (ORCPT ); Tue, 31 Mar 2015 15:56:38 -0400 Received: from mailrelay112.isp.belgacom.be ([195.238.20.139]:16775 "EHLO mailrelay112.isp.belgacom.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753650AbbCaT4c (ORCPT ); Tue, 31 Mar 2015 15:56:32 -0400 X-Belgacom-Dynamic: yes X-Cloudmark-SP-Filtered: true X-Cloudmark-SP-Result: v=1.1 cv=U3bOsIs4jTLKnNjizNqmwgH4x/ZVWD6r1e7q5IgUJPc= c=1 sm=2 a=SP5AAPQoICiYEzk6x5gA:9 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2BFBwDp+hpV/38KQFdcgwZSXLJSCAEBAQUBe5IdhXuBRU0BAQEBAQF9hHEjgRo3iDMBzgUshg+KEh2EFwWUVIYDgVeSZCKBRW2BPjwxgkMBAQE From: Fabian Frederick To: linux-kernel@vger.kernel.org Cc: Fabian Frederick , Andy Whitcroft , Joe Perches Subject: [PATCH V3 linux-next] checkpatch: don't ask for asm/file.h to linux/file.h unconditionally Date: Tue, 31 Mar 2015 21:56:25 +0200 Message-Id: <1427831785-20990-1-git-send-email-fabf@skynet.be> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently checkpatch warns when asm/file.h is included and linux/file.h exists. That conversion can be made when linux/file.h includes asm/file.h which is not always the case.(See signal.h) Signed-off-by: Fabian Frederick --- V3: Only grep when $root/$checkfile exists (suggested by Joe Perches) V2: Apply suggestions by Joe Perches: -Remove superfluous -i in grep -Use $root to make checkpatch callable from anywhere -Process all include cases. scripts/checkpatch.pl | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index d54a814..c72e7ee 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -4242,7 +4242,8 @@ sub process { } } -#warn if is #included and is available (uses RAW line) +# warn if is #included and is available and includes +# itself (uses RAW line) if ($tree && $rawline =~ m{^.\s*\#\s*include\s*\}) { my $file = "$1.h"; my $checkfile = "include/linux/$file"; @@ -4250,12 +4251,15 @@ sub process { $realfile ne $checkfile && $1 !~ /$allowed_asm_includes/) { - if ($realfile =~ m{^arch/}) { - CHK("ARCH_INCLUDE_LINUX", - "Consider using #include instead of \n" . $herecurr); - } else { - WARN("INCLUDE_LINUX", - "Use #include instead of \n" . $herecurr); + my $asminclude = `grep -Ec "#include\\s+" $root/$checkfile`; + if ($asminclude > 0) { + if ($realfile =~ m{^arch/}) { + CHK("ARCH_INCLUDE_LINUX", + "Consider using #include instead of \n" . $herecurr); + } else { + WARN("INCLUDE_LINUX", + "Use #include instead of \n" . $herecurr); + } } } } -- 1.9.1