提交 90ad30e5 编写于 作者: J Joe Perches 提交者: Linus Torvalds

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: NJoe Perches <joe@perches.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 0ab90191
......@@ -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",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册