]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
checkpatch: warn on unnecessary line continuations
authorJoe Perches <joe@perches.com>
Fri, 9 Nov 2012 03:04:54 +0000 (14:04 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 9 Nov 2012 03:09:00 +0000 (14:09 +1100)
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>
scripts/checkpatch.pl

index f18750e3bd6c290b285464b193d7d65972b6de19..d4f61a6fed5db245630ac6c8f0f453a4ef381d6a 100755 (executable)
@@ -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: