Skip to content

Commit

Permalink
checkpatch: add test for consecutive string fragments
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Joe Perches authored and Linus Torvalds committed Dec 11, 2014
1 parent 0ab9019 commit 90ad30e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -4464,6 +4464,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",
Expand Down

0 comments on commit 90ad30e

Please sign in to comment.