Skip to contentSkip to conversation

checkpatch: Add --strict test for concatenated string elements

PATCH New Joe Perches 1 participant 1 message Sep 1, 2014 Checkpatch

lore
Share & tools
lore

Joe Perches

author maintainer
#0 lore raw

PATCH 1/1 checkpatch: Add --strict test for concatenated string elements

Using a space between concatenated string elements is easier for a human to read.

ie:
"String"FOO"bar"

is easier to read as:

"String" FOO "bar"

So suggest this style with a --strict command line option.

---
 scripts/checkpatch.pl | 6 ++++++
 1 file changed, 6 insertions(+)
scripts/checkpatch.pl +6 -0
index d89857d..48a2d8c 100755
@@ -4335,6 +4335,12 @@ sub process {
 			     "Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n" . $herecurr);
 		}
 
+# concatenated string without spaces between elements
+		if ($line =~ /"X+"[A-Z_]+/ || $line =~ /[A-Z_]+"X+"/) {
+			CHK("CONCATENATED_STRING",
+			    "Concatenated strings should use spaces between elements\n" . $herecurr);
+		}
+
 # warn about #if 0
 		if ($line =~ /^.\s*\#\s*if\s+0\b/) {
 			CHK("REDUNDANT_CODE",