public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] checkpatch: Add test for consecutive string fragments
@ 2014-11-07  6:39 Joe Perches
  0 siblings, 0 replies; only message in thread
From: Joe Perches @ 2014-11-07  6:39 UTC (permalink / raw)
  To: Andrew Morton; +Cc: LKML

Emit a warning when single line string coalescing occurs.

Code that uses compiler string concatenation on a single line like:
	printk("foo" "bar");
is generally better to read concatenated like:
	printk("foobar");

Signed-off-by: Joe Perches <joe@perches.com>
---
 scripts/checkpatch.pl | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 893cbd5..508037a 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4462,6 +4462,12 @@ sub process {
 			    "Concatenated strings should use spaces between elements\n" . $herecurr);
 		}
 
+# uncoalesced string fragments
+		if ($line =~ /"X*"\s*"/) {
+			WARN("STRING_FRAGMENTS",
+			     "Consecutive strings are generally better as a single string\n" . $herecurr);
+		}
+
 # warn about #if 0
 		if ($line =~ /^.\s*\#\s*if\s+0\b/) {
 			CHK("REDUNDANT_CODE",



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-11-07  6:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-07  6:39 [PATCH] checkpatch: Add test for consecutive string fragments Joe Perches

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