linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 1/1 linux-next] checkpatch: don't ask for asm/file.h to linux/file.h unconditionally
@ 2015-03-30 20:36 Fabian Frederick
  2015-03-30 20:49 ` Joe Perches
  0 siblings, 1 reply; 3+ messages in thread
From: Fabian Frederick @ 2015-03-30 20:36 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>
---
 scripts/checkpatch.pl | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index d54a814..5824829 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4242,13 +4242,16 @@ 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";
+			my $asminclude = `grep -ci "#include <asm/$file.h>" $checkfile`;
 			if (-f "$root/$checkfile" &&
 			    $realfile ne $checkfile &&
-			    $1 !~ /$allowed_asm_includes/)
+			    $1 !~ /$allowed_asm_includes/ &&
+			    $asminclude > 0 )
 			{
 				if ($realfile =~ m{^arch/}) {
 					CHK("ARCH_INCLUDE_LINUX",
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RFC 1/1 linux-next] checkpatch: don't ask for asm/file.h to linux/file.h unconditionally
  2015-03-30 20:36 [RFC 1/1 linux-next] checkpatch: don't ask for asm/file.h to linux/file.h unconditionally Fabian Frederick
@ 2015-03-30 20:49 ` Joe Perches
  2015-03-31 19:09   ` Fabian Frederick
  0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2015-03-30 20:49 UTC (permalink / raw)
  To: Fabian Frederick; +Cc: linux-kernel, Andy Whitcroft

On Mon, 2015-03-30 at 22:36 +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)
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> -#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";
> +			my $asminclude = `grep -ci "#include <asm/$file.h>" $checkfile`;

This won't work with #include forms like:
	#include	<asm/foo.h>
or when checkpatch is run from somewhere other
than the top of tree.

why the -i?

>  			if (-f "$root/$checkfile" &&
>  			    $realfile ne $checkfile &&
> -			    $1 !~ /$allowed_asm_includes/)
> +			    $1 !~ /$allowed_asm_includes/ &&
> +			    $asminclude > 0 )
>  			{
>  				if ($realfile =~ m{^arch/}) {
>  					CHK("ARCH_INCLUDE_LINUX",



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC 1/1 linux-next] checkpatch: don't ask for asm/file.h to linux/file.h unconditionally
  2015-03-30 20:49 ` Joe Perches
@ 2015-03-31 19:09   ` Fabian Frederick
  0 siblings, 0 replies; 3+ messages in thread
From: Fabian Frederick @ 2015-03-31 19:09 UTC (permalink / raw)
  To: Joe Perches; +Cc: linux-kernel, Andy Whitcroft



> On 30 March 2015 at 22:49 Joe Perches <joe@perches.com> wrote:
>
>
> On Mon, 2015-03-30 at 22:36 +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)
> []
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> []
> > -#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";
> > +                   my $asminclude = `grep -ci "#include <asm/$file.h>"
> > $checkfile`;
>
> This won't work with #include forms like:
>       #include        <asm/foo.h>
> or when checkpatch is run from somewhere other
> than the top of tree.
>
> why the -i?

Hi Joe,

This was just an RFC. I guess you're ok with the idea so I added your
suggestions in V2.

Regards,
Fabian

>
> >                     if (-f "$root/$checkfile" &&
> >                         $realfile ne $checkfile &&
> > -                       $1 !~ /$allowed_asm_includes/)
> > +                       $1 !~ /$allowed_asm_includes/ &&
> > +                       $asminclude > 0 )
> >                     {
> >                             if ($realfile =~ m{^arch/}) {
> >                                     CHK("ARCH_INCLUDE_LINUX",
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-31 19:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-30 20:36 [RFC 1/1 linux-next] checkpatch: don't ask for asm/file.h to linux/file.h unconditionally Fabian Frederick
2015-03-30 20:49 ` Joe Perches
2015-03-31 19:09   ` Fabian Frederick

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).