checkpatch: add check for line continuations in quoted strings

Add a warning for unterminated quoted strings with line continuations as
these frequently add unwanted whitespace.

Signed-off-by: Joe Perches <joe@perches.com>
Cc: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Joe Perches 2011-05-24 17:13:39 -07:00 committed by Linus Torvalds
parent 5ca43f6c3b
commit 428e2fdc4e
1 changed files with 5 additions and 0 deletions

View File

@ -2748,6 +2748,11 @@ sub process {
WARN("sizeof(& should be avoided\n" . $herecurr); WARN("sizeof(& should be avoided\n" . $herecurr);
} }
# check for line continuations in quoted strings with odd counts of "
if ($rawline =~ /\\$/ && $rawline =~ tr/"/"/ % 2) {
WARN("Avoid line continuations in quoted strings\n" . $herecurr);
}
# check for new externs in .c files. # check for new externs in .c files.
if ($realfile =~ /\.c$/ && defined $stat && if ($realfile =~ /\.c$/ && defined $stat &&
$stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s) $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s)