Skip to content

Commit

Permalink
checkpatch: warn on unnecessary line continuations
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Joe Perches authored and Linus Torvalds committed Dec 18, 2012
1 parent 0ad50c3 commit 5023d34
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 5023d34

Please sign in to comment.