Skip to contentSkip to conversation

checkpatch: Avoid "spaces required around that ':'" false positive

PATCH New Joe Perches 1 participant 1 message Apr 14, 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

PATCH 1/1 checkpatch: Avoid "spaces required around that ':'" false positive

Since commit 1f65f947a6a8 ("checkpatch: add checks for question mark and colon spacing") back in 2008, checkpatch has reported false positive for asm volatile uses of "::" checkpatch thinks colons should always have spaces around it.

Add an exception for colons with colons on either side for this valid asm volatile (and c++) use.

---

Quoted 5 lines · Yehuda Yitschak

i believe i found a false positive in checkpatch script
When embedding ARM assembly code in C files checkpatch shouts about spaces after semicolon but that's the syntax of inline assembly.
ERROR: spaces required around that ':' (ctx:WxO)
#43: FILE: arch/arm64/kernel/perf_event.c:1221:
+ asm volatile("msr pmuserenr_el0, %0" :: "r" (0xf));

 scripts/checkpatch.pl | 8 ++++++++
 1 file changed, 8 insertions(+)
scripts/checkpatch.pl +8 -0
index 78a951f..bf1cc43 100755
@@ -3837,6 +3837,14 @@ sub process {
 					    	$ok = 1;
 					}
 
+					# for asm volatile statements
+					# ignore a colon with another
+					# colon immediately before or after
+					if (($op eq ':') &&
+					    ($ca =~ /:$/ || $cc =~ /^:/)) {
+						$ok = 1;
+					}
+
 					# messages are ERROR, but ?: are CHK
 					if ($ok == 0) {
 						my $msg_type = \&ERROR;