linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: checkpatch.pl false positive
       [not found] <DB6PR0901MB1173A77EA985D67344E42029F5E50@DB6PR0901MB1173.eurprd09.prod.outlook.com>
@ 2017-05-22 18:52 ` Joe Perches
  0 siblings, 0 replies; 3+ messages in thread
From: Joe Perches @ 2017-05-22 18:52 UTC (permalink / raw)
  To: Antonio Niño Díaz, apw; +Cc: LKML

On Fri, 2017-05-19 at 09:57 +0000, Antonio Niño Díaz wrote:
> Hello,

Hi.

> I think I've hit a corner case in checkpatch.pl. It is easy to reproduce, just create a patch with a new line such as:
> 
> #define MY_HEADER <header.h>

[ checkpatch outputs ]

> config.h:9: ERROR: spaces required around that '<' (ctx:WxV)
> +#define MY_HEADER <header.h>                 ^
> config.h:9: ERROR: spaces required around that '>' (ctx:VxE)
> +#define MY_HEADER <header.h>

Yeah, checkpatch doesn't know about the #define before the other
things
it tests.

> Will you add this as an exception, or it is not an issue for
> you as the Linux kernel doesn't really use this weird system?

Probably not as it's not a kernel usage and
I can't think of a decent way to avoid it.

maybe some substitution like

$rawline =~ s/^(\s*#\s*define\s+\w+\s+)<([^>]+>)/\1"\2"/

could help, but it's pretty obscure and probably not
used in many other projects.

Maybe you could add and keep it local to your use.

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

* RE: checkpatch.pl false positive
  2014-07-22 19:23 ` Joe Perches
@ 2014-07-22 19:46   ` Hartley Sweeten
  0 siblings, 0 replies; 3+ messages in thread
From: Hartley Sweeten @ 2014-07-22 19:46 UTC (permalink / raw)
  To: Joe Perches; +Cc: Andy Whitcroft, LKML

On Tuesday, July 22, 2014 12:23 PM, Joe Perches wrote:
> On Tue, 2014-07-22 at 17:30 +0000, Hartley Sweeten wrote:
>> Joe,
>> 
>> I think this is a false positive, at least the check message appears
>> incorrect:
>> 
>> CHECK: No space is necessary after a cast
>> #66: FILE: arch/arm/mach-ep93xx/include/mach/platform.h:66:
>> +static inline int crunch_init(void) { return 0; }
>
> Yeah, it's a false positive introduced by -next
> commit 89da401f6cff ("checkpatch: improve "no space after cast" test")
>
> Try this?
> ---
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 2258497..644c2d5 100755
> --- a/scripts/checkpatch.pl
>+++ b/scripts/checkpatch.pl
> @ @ -2418,7 +2418,7 @@ sub process {
>  			}
>  		}
>  
> -		if ($line =~ /^\+.*\(\s*$Type\s*\)[ \t]+(?!$Assignment|$Arithmetic)/) {
> +		if ($line =~ /^\+.*\(\s*$Type\s*\)[ \t]+(?!$Assignment|$Arithmetic|{)/) {
> 			if (CHK("SPACING",
> 				"No space is necessary after a cast\n" . $herecurr) &&
>  			    $fix) {

That fixed it.

Thanks,
Hartley



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

* Re: checkpatch.pl false positive
       [not found] <DC148C5AA1CEBA4E87973D432B1C2D8825F13B6F@P3PWEX4MB008.ex4.secureserver.net>
@ 2014-07-22 19:23 ` Joe Perches
  2014-07-22 19:46   ` Hartley Sweeten
  0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2014-07-22 19:23 UTC (permalink / raw)
  To: Hartley Sweeten; +Cc: Andy Whitcroft, LKML


On Tue, 2014-07-22 at 17:30 +0000, Hartley Sweeten wrote:
> Joe,
> 
> I think this is a false positive, at least the check message appears
> incorrect:
> 
> CHECK: No space is necessary after a cast
> #66: FILE: arch/arm/mach-ep93xx/include/mach/platform.h:66:
> +static inline int crunch_init(void) { return 0; }

Yeah, it's a false positive introduced by -next
commit 89da401f6cff ("checkpatch: improve "no space after cast" test")

Try this?
---
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2258497..644c2d5 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2418,7 +2418,7 @@ sub process {
 			}
 		}
 
-		if ($line =~ /^\+.*\(\s*$Type\s*\)[ \t]+(?!$Assignment|$Arithmetic)/) {
+		if ($line =~ /^\+.*\(\s*$Type\s*\)[ \t]+(?!$Assignment|$Arithmetic|{)/) {
 			if (CHK("SPACING",
 				"No space is necessary after a cast\n" . $herecurr) &&
 			    $fix) {



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

end of thread, other threads:[~2017-05-22 18:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <DB6PR0901MB1173A77EA985D67344E42029F5E50@DB6PR0901MB1173.eurprd09.prod.outlook.com>
2017-05-22 18:52 ` checkpatch.pl false positive Joe Perches
     [not found] <DC148C5AA1CEBA4E87973D432B1C2D8825F13B6F@P3PWEX4MB008.ex4.secureserver.net>
2014-07-22 19:23 ` Joe Perches
2014-07-22 19:46   ` Hartley Sweeten

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