checkpatch: warn on unnecessary line continuations

When the previous line is not a line continuation and the current line has
a line continuation but is not a #define, emit a warning.

Signed-off-by: Joe Perches <joe@perches.com>
Cc: Peter Hurley <peter@hurleysoftware.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 2012-12-17 16:01:47 -08:00 committed by Linus Torvalds
parent 0ad50c3896
commit 5023d3472d
1 changed files with 9 additions and 0 deletions

View File

@ -3013,6 +3013,15 @@ sub process {
"Macros with complex values should be enclosed in parenthesis\n" . "$herectx");
}
}
# check for line continuations outside of #defines
} else {
if ($prevline !~ /^..*\\$/ &&
$line =~ /^\+.*\\$/) {
WARN("LINE_CONTINUATIONS",
"Avoid unnecessary line continuations\n" . $herecurr);
}
}
# do {} while (0) macro tests: