From 428e2fdc4ecee2312829e97549f99c12312f4faf Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Tue, 24 May 2011 17:13:39 -0700 Subject: [PATCH] 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 Cc: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/checkpatch.pl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index d8670810db65..5c9672951077 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2748,6 +2748,11 @@ sub process { 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. if ($realfile =~ /\.c$/ && defined $stat && $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s)