* [PATCH V3 linux-next] checkpatch: don't ask for asm/file.h to linux/file.h unconditionally
@ 2015-03-31 19:56 Fabian Frederick
2015-03-31 20:14 ` Joe Perches
0 siblings, 1 reply; 2+ messages in thread
From: Fabian Frederick @ 2015-03-31 19:56 UTC (permalink / raw)
To: linux-kernel; +Cc: Fabian Frederick, Andy Whitcroft, Joe Perches
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 <fabf@skynet.be>
---
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 <asm/foo.h> is #included and <linux/foo.h> is available (uses RAW line)
+# warn if <asm/foo.h> is #included and <linux/foo.h> is available and includes
+# itself <asm/foo.h> (uses RAW line)
if ($tree && $rawline =~ m{^.\s*\#\s*include\s*\<asm\/(.*)\.h\>}) {
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 <linux/$file> instead of <asm/$file>\n" . $herecurr);
- } else {
- WARN("INCLUDE_LINUX",
- "Use #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
+ my $asminclude = `grep -Ec "#include\\s+<asm/$file>" $root/$checkfile`;
+ if ($asminclude > 0) {
+ if ($realfile =~ m{^arch/}) {
+ CHK("ARCH_INCLUDE_LINUX",
+ "Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
+ } else {
+ WARN("INCLUDE_LINUX",
+ "Use #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
+ }
}
}
}
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH V3 linux-next] checkpatch: don't ask for asm/file.h to linux/file.h unconditionally
2015-03-31 19:56 [PATCH V3 linux-next] checkpatch: don't ask for asm/file.h to linux/file.h unconditionally Fabian Frederick
@ 2015-03-31 20:14 ` Joe Perches
0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2015-03-31 20:14 UTC (permalink / raw)
To: Fabian Frederick; +Cc: linux-kernel, Andy Whitcroft, Andrew Morton
On Tue, 2015-03-31 at 21:56 +0200, Fabian Frederick wrote:
> 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)
OK by me.
I would have done it directly in the if,
but no real worries either way.
Andrew Morton is the common path to get checkpatch
patches upstream, so I cc'd him on this reply.
If he doesn't pick it up within a couple/few weeks,
send it again.
cheers, Joe
> Signed-off-by: Fabian Frederick <fabf@skynet.be>
> ---
> 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 <asm/foo.h> is #included and <linux/foo.h> is available (uses RAW line)
> +# warn if <asm/foo.h> is #included and <linux/foo.h> is available and includes
> +# itself <asm/foo.h> (uses RAW line)
> if ($tree && $rawline =~ m{^.\s*\#\s*include\s*\<asm\/(.*)\.h\>}) {
> 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 <linux/$file> instead of <asm/$file>\n" . $herecurr);
> - } else {
> - WARN("INCLUDE_LINUX",
> - "Use #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
> + my $asminclude = `grep -Ec "#include\\s+<asm/$file>" $root/$checkfile`;
> + if ($asminclude > 0) {
> + if ($realfile =~ m{^arch/}) {
> + CHK("ARCH_INCLUDE_LINUX",
> + "Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
> + } else {
> + WARN("INCLUDE_LINUX",
> + "Use #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
> + }
> }
> }
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-03-31 20:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-31 19:56 [PATCH V3 linux-next] checkpatch: don't ask for asm/file.h to linux/file.h unconditionally Fabian Frederick
2015-03-31 20:14 ` Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).