summaryrefslogtreecommitdiffstats
path: root/scripts/checkpatch.pl
diff options
context:
space:
mode:
authorAndy Whitcroft <apw@shadowen.org>2008-07-23 21:29:03 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-24 10:47:25 -0700
commit53210168feeff9a3c780bd42f69936d4c12381d5 (patch)
tree7f637f7e8a1c01b0a5fd4456d31da4868472a95d /scripts/checkpatch.pl
parent8d31cfcecf67563d70cd68616cb8fb4384f24b51 (diff)
downloadtalos-op-linux-53210168feeff9a3c780bd42f69936d4c12381d5.tar.gz
talos-op-linux-53210168feeff9a3c780bd42f69936d4c12381d5.zip
checkpatch: toughen trailing if statement checks and extend them to while and for
Extend the trailing statement checks to report a trailing semi-colon ';' as we really want it on the next line and indented so it is really really obvious. Also extend the tests to include while and for. Signed-off-by: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-xscripts/checkpatch.pl10
1 files changed, 5 insertions, 5 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e7c8ab1b54bd..8616baee0aeb 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1269,8 +1269,8 @@ sub process {
$ctx_ln++;
}
- ##print "realcnt<$realcnt> ctx_cnt<$ctx_cnt>\n";
- ##print "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n";
+ #print "realcnt<$realcnt> ctx_cnt<$ctx_cnt>\n";
+ #print "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n";
if ($ctx !~ /{\s*/ && defined($lines[$ctx_ln -1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/) {
ERROR("that open brace { should be on the previous line\n" .
@@ -1713,7 +1713,7 @@ sub process {
}
# Check for illegal assignment in if conditional.
- if ($line =~ /\bif\s*\(/) {
+ if ($line =~ /\b(?:if|while|for)\s*\(/ && $line !~ /^.\s*#/) {
my ($s, $c) = ($stat, $cond);
if ($c =~ /\bif\s*\(.*[^<>!=]=[^=].*/) {
@@ -1725,8 +1725,8 @@ sub process {
substr($s, 0, length($c), '');
$s =~ s/\n.*//g;
$s =~ s/$;//g; # Remove any comments
- if (length($c) && $s !~ /^\s*({|;|)\s*\\*\s*$/ &&
- $c !~ /^.\s*\#\s*if/)
+ if (length($c) && $s !~ /^\s*{?\s*\\*\s*$/ &&
+ $c !~ /}\s*while\s*/)
{
ERROR("trailing statements should be on next line\n" . $herecurr);
}
OpenPOWER on IntegriCloud