diff options
author | 2014-12-10 15:51:59 -0800 | |
---|---|---|
committer | 2014-12-10 17:41:12 -0800 | |
commit | 90ad30e5b2a759333f06eee64e59a0d886d02036 (patch) | |
tree | d656578867675998a058c62fee5436c2de4851f1 /scripts | |
parent | checkpatch: add --strict preference for #defines using BIT(foo) (diff) | |
download | linux-90ad30e5b2a759333f06eee64e59a0d886d02036.tar.gz linux-90ad30e5b2a759333f06eee64e59a0d886d02036.tar.bz2 linux-90ad30e5b2a759333f06eee64e59a0d886d02036.zip |
checkpatch: add test for consecutive string fragments
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>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/checkpatch.pl | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index d06b6be2841e..5e63dce2e428 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -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", |