Skip to contentSkip to conversation

false positives with checkpatch

DISCUSSION Joe Perches 3 participants 3 messages Aug 7, 2015 1 message not in the archive Checkpatch

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Joe Perches

author maintainer
#1 lore raw
Quoted 9 lines · Ross Zwisler

When running checkpatch.pl against my latest patch set, I hit what I think are two false positives. Here are the related lines:

+static inline void flush_cache_pmem(void __pmem *addr, size_t size) +{
+ if (arch_has_pmem_api())
+ arch_flush_cache_pmem(addr, size);
+}

Quoted 8 lines

The error was:

	ERROR: need consistent spacing around '*' (ctx:WxV)
	#88: FILE: include/linux/pmem.h:167:
	+static inline void flush_cache_pmem(void __pmem *addr, size_t size)
							 ^

The (void __annotation *variable) syntax is correct, I believe, and is used consistently for both __iomem and __pmem annotations.

checkpatch doesn't know what a __pmem is. Neither did I until a second ago.

Are there any other sparse annotations that were added by this subsystem? (I don't notice any)

They need to be added to checkpatch's $Sparse use so there's a patch proposal below this.

It looks like compiler.h's #define __safe is unused in the linux kernel and it could be deleted as it's not a gcc attribute.

Does anyone know?

Linus' commit is unrevealing.

commit e6b8f25bd950947d06c59432cbafd320dda66abf

Author: Linus Torvalds <[email protected]>
Date:   Fri Apr 16 03:49:32 2004 -0700

Add sparse __safe annotation

---
 scripts/checkpatch.pl | 1 +
 1 file changed, 1 insertion(+)
scripts/checkpatch.pl +1 -0
index fd8e502..6362ec3 100755
@@ -264,6 +264,7 @@ our $Sparse	= qr{
 			__kernel|
 			__force|
 			__iomem|
+			__pmem|
 			__must_check|
 			__init_refok|
 			__kprobes|
maintainer
#2 lore raw
Quoted 51 lines · Joe Perches
Quoted 9 lines · Ross Zwisler

When running checkpatch.pl against my latest patch set, I hit what I think are two false positives. Here are the related lines:

+static inline void flush_cache_pmem(void __pmem *addr, size_t size) +{
+ if (arch_has_pmem_api())
+ arch_flush_cache_pmem(addr, size);
+}

Quoted 8 lines

The error was:

	ERROR: need consistent spacing around '*' (ctx:WxV)
	#88: FILE: include/linux/pmem.h:167:
	+static inline void flush_cache_pmem(void __pmem *addr, size_t size)
							 ^

The (void __annotation *variable) syntax is correct, I believe, and is used consistently for both __iomem and __pmem annotations.

checkpatch doesn't know what a __pmem is. Neither did I until a second ago.

Are there any other sparse annotations that were added by this subsystem? (I don't notice any)

They need to be added to checkpatch's $Sparse use so there's a patch proposal below this.

It looks like compiler.h's #define __safe is unused in the linux kernel and it could be deleted as it's not a gcc attribute.

Does anyone know?

Linus' commit is unrevealing.

commit e6b8f25bd950947d06c59432cbafd320dda66abf

Author: Linus Torvalds <[email protected]>
Date:   Fri Apr 16 03:49:32 2004 -0700

Add sparse __safe annotation

---
 scripts/checkpatch.pl | 1 +
 1 file changed, 1 insertion(+)
scripts/checkpatch.pl +0 -0
index fd8e502..6362ec3 100755

scripts/checkpatch.pl our $Sparse = qr{ · line 270

Quoted 7 lines
scripts/checkpatch.pl +1 -0
@@ -264,6 +264,7 @@ our $Sparse	= qr{
 			__kernel|
 			__force|
 			__iomem|
+			__pmem|
 			__must_check|
 			__init_refok|
 			__kprobes|

Looks good to me.

-apw

Reviewed-by
#3 lore raw
In reply to Joe Perches
Quoted 19 lines · Joe Perches
Quoted 9 lines · Ross Zwisler

When running checkpatch.pl against my latest patch set, I hit what I think are two false positives. Here are the related lines:

+static inline void flush_cache_pmem(void __pmem *addr, size_t size) +{
+ if (arch_has_pmem_api())
+ arch_flush_cache_pmem(addr, size);
+}

Quoted 8 lines

The error was:

	ERROR: need consistent spacing around '*' (ctx:WxV)
	#88: FILE: include/linux/pmem.h:167:
	+static inline void flush_cache_pmem(void __pmem *addr, size_t size)
							 ^

The (void __annotation *variable) syntax is correct, I believe, and is used consistently for both __iomem and __pmem annotations.

Quoted 5 lines

checkpatch doesn't know what a __pmem is.
Neither did I until a second ago.

Are there any other sparse annotations that were
added by this subsystem? (I don't notice any)

This was the only sparse annotation that we added.

Quoted 9 lines
---
 scripts/checkpatch.pl | 1 +
 1 file changed, 1 insertion(+)
scripts/checkpatch.pl +0 -0
index fd8e502..6362ec3 100755

scripts/checkpatch.pl our $Sparse = qr{ · line 270

Quoted 7 lines
scripts/checkpatch.pl +1 -0
@@ -264,6 +264,7 @@ our $Sparse	= qr{
 			__kernel|
 			__force|
 			__iomem|
+			__pmem|
 			__must_check|
 			__init_refok|
 			__kprobes|

Yep, this works for me.