mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* checkpatch.pl: false warning about "-p0 patch"
@ 2013-08-22 21:45 Brian Norris
  2013-08-22 21:57 ` Joe Perches
  0 siblings, 1 reply; 4+ messages in thread
From: Brian Norris @ 2013-08-22 21:45 UTC (permalink / raw)
  To: Andy Whitcroft, Joe Perches; +Cc: Linux Kernel

Hello,

I have received what appears to be a false warning from checkpatch.pl when
checking a patch named 'b':

    $ scripts/checkpatch.pl b
    WARNING: patch prefix 'b' exists, appears to be a -p0 patch

    total: 0 errors, 1 warnings, 16 lines checked

    b has style problems, please review.

    If any of these errors are false positives, please report
    them to the maintainer, see CHECKPATCH in MAINTAINERS.

It appears that I can trigger this warning with any arbitrary commit. The
following bash script gives me at least one warning for everything in Linus'
tree:

  for i in {0..100}
  do
      git format-patch -1 HEAD~$i --stdout > b
      scripts/checkpatch.pl b
  done

I have also seen this warning on patches with other names, but I'm not
reproducing that right now.

Brian

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

* Re: checkpatch.pl: false warning about "-p0 patch"
  2013-08-22 21:45 checkpatch.pl: false warning about "-p0 patch" Brian Norris
@ 2013-08-22 21:57 ` Joe Perches
  2013-08-22 22:14   ` Brian Norris
  0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2013-08-22 21:57 UTC (permalink / raw)
  To: Brian Norris; +Cc: Andy Whitcroft, Linux Kernel

On Thu, 2013-08-22 at 14:45 -0700, Brian Norris wrote:
> Hello,

Hello.

> I have received what appears to be a false warning from checkpatch.pl when
> checking a patch named 'b':
> 
>     $ scripts/checkpatch.pl b
>     WARNING: patch prefix 'b' exists, appears to be a -p0 patch
> 
>     total: 0 errors, 1 warnings, 16 lines checked
> 
>     b has style problems, please review.
> 
>     If any of these errors are false positives, please report
>     them to the maintainer, see CHECKPATCH in MAINTAINERS.
> 
> It appears that I can trigger this warning with any arbitrary commit. The
> following bash script gives me at least one warning for everything in Linus'
> tree:
> 
>   for i in {0..100}
>   do
>       git format-patch -1 HEAD~$i --stdout > b
>       scripts/checkpatch.pl b
>   done
> 
> I have also seen this warning on patches with other names, but I'm not
> reproducing that right now.

checkpatch can use stdin as well as files/patches.

Try this instead of creating a temporary file:

for i in {0..100}
do
    git format-patch -1 --stdout HEAD~$1 | ./scripts/checkpatch.pl -
done



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

* Re: checkpatch.pl: false warning about "-p0 patch"
  2013-08-22 21:57 ` Joe Perches
@ 2013-08-22 22:14   ` Brian Norris
  2013-08-22 22:30     ` Joe Perches
  0 siblings, 1 reply; 4+ messages in thread
From: Brian Norris @ 2013-08-22 22:14 UTC (permalink / raw)
  To: Joe Perches; +Cc: Andy Whitcroft, Linux Kernel

On Thu, Aug 22, 2013 at 2:57 PM, Joe Perches <joe@perches.com> wrote:
> On Thu, 2013-08-22 at 14:45 -0700, Brian Norris wrote:
>> Hello,
>
> Hello.
>
>> I have received what appears to be a false warning from checkpatch.pl when
>> checking a patch named 'b':
>>
>>     $ scripts/checkpatch.pl b
>>     WARNING: patch prefix 'b' exists, appears to be a -p0 patch
>>
>>     total: 0 errors, 1 warnings, 16 lines checked
>>
>>     b has style problems, please review.
>>
>>     If any of these errors are false positives, please report
>>     them to the maintainer, see CHECKPATCH in MAINTAINERS.
>>
>> It appears that I can trigger this warning with any arbitrary commit. The
>> following bash script gives me at least one warning for everything in Linus'
>> tree:
>>
>>   for i in {0..100}
>>   do
>>       git format-patch -1 HEAD~$i --stdout > b
>>       scripts/checkpatch.pl b
>>   done
>>
>> I have also seen this warning on patches with other names, but I'm not
>> reproducing that right now.
>
> checkpatch can use stdin as well as files/patches.
>
> Try this instead of creating a temporary file:
>
> for i in {0..100}
> do
>     git format-patch -1 --stdout HEAD~$1 | ./scripts/checkpatch.pl -
> done

Thanks for the tip. This for-loop was just a litmus test to show that
checkpatch.pl is indeed failing simply because of the filename of 'b'.
So I would consider that a checkpatch.pl bug.

But now, I realized the problem is simply with the existence of a file
named 'b'. That is, checkpatch will give a warning for this:

  touch b
  git format-patch -1 --stdout | scripts/checkpatch.pl -
  WARNING: patch prefix 'b' exists, appears to be a -p0 patch

  WARNING: patch prefix 'b' exists, appears to be a -p0 patch

  WARNING: patch prefix 'b' exists, appears to be a -p0 patch
  ...

Is that expected?

Brian

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

* Re: checkpatch.pl: false warning about "-p0 patch"
  2013-08-22 22:14   ` Brian Norris
@ 2013-08-22 22:30     ` Joe Perches
  0 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2013-08-22 22:30 UTC (permalink / raw)
  To: Brian Norris; +Cc: Andy Whitcroft, Linux Kernel

On Thu, 2013-08-22 at 15:14 -0700, Brian Norris wrote:
> I realized the problem is simply with the existence of a file
> named 'b'. That is, checkpatch will give a warning for this:
>   touch b
>   git format-patch -1 --stdout | scripts/checkpatch.pl -
>   WARNING: patch prefix 'b' exists, appears to be a -p0 patch
> Is that expected?

Yes.  Basically, don't have a file (or a directory)
named a or b in the kernel root directory.

			if (!$file && $tree && $p1_prefix ne '' &&
			    -e "$root/$p1_prefix") {
				WARN("PATCH_PREFIX",
				     "patch prefix '$p1_prefix' exists, appears to be a -p0 patch\n");
			}



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

end of thread, other threads:[~2013-08-22 22:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-22 21:45 checkpatch.pl: false warning about "-p0 patch" Brian Norris
2013-08-22 21:57 ` Joe Perches
2013-08-22 22:14   ` Brian Norris
2013-08-22 22:30     ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®