summaryrefslogtreecommitdiffstats
path: root/scripts/checkpatch.pl
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2014-04-03 17:49:32 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-03 19:21:15 -0400
commit91cb5195ff224dd9044cf927f80d9c633cdcffec (patch)
tree6c01f3e806877c640f5e2c09d9965cfd3c9d3725 /scripts/checkpatch.pl
parent7ebd05ef1646e8cbef54e38343722741a4744626 (diff)
checkpatch: expand parenthesis alignment test to declarations, functions and assignments
Currently the parenthesis alignment test works only on misalignments of if statements like if (foo(bar, baz) Expand the test to find misalignments like: static inline int foo(int bar, int baz) and foo(bar, baz); and foo = bar(baz, qux); Expand the $Inline keyword for __inline and __inline__ too. Add $Inline to $Declare so it also matches "static inline <foo>". These checks are only performed with --strict. Signed-off-by: Joe Perches <joe@perches.com> 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, 6 insertions, 4 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index fbb1b7e88e87..d3dcb370fc37 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -281,7 +281,7 @@ our $Attribute = qr{
281 __weak 281 __weak
282 }x; 282 }x;
283our $Modifier; 283our $Modifier;
284our $Inline = qr{inline|__always_inline|noinline}; 284our $Inline = qr{inline|__always_inline|noinline|__inline|__inline__};
285our $Member = qr{->$Ident|\.$Ident|\[[^]]*\]}; 285our $Member = qr{->$Ident|\.$Ident|\[[^]]*\]};
286our $Lval = qr{$Ident(?:$Member)*}; 286our $Lval = qr{$Ident(?:$Member)*};
287 287
@@ -304,6 +304,8 @@ our $Operators = qr{
304 &&|\|\||,|\^|\+\+|--|&|\||$Arithmetic 304 &&|\|\||,|\^|\+\+|--|&|\||$Arithmetic
305 }x; 305 }x;
306 306
307our $c90_Keywords = qr{do|for|while|if|else|return|goto|continue|switch|default|case|break}x;
308
307our $NonptrType; 309our $NonptrType;
308our $NonptrTypeWithAttr; 310our $NonptrTypeWithAttr;
309our $Type; 311our $Type;
@@ -429,7 +431,7 @@ sub build_types {
429 (?:(?:\s|\*|\[\])+\s*const|(?:\s|\*|\[\])+|(?:\s*\[\s*\])+)? 431 (?:(?:\s|\*|\[\])+\s*const|(?:\s|\*|\[\])+|(?:\s*\[\s*\])+)?
430 (?:\s+$Inline|\s+$Modifier)* 432 (?:\s+$Inline|\s+$Modifier)*
431 }x; 433 }x;
432 $Declare = qr{(?:$Storage\s+)?$Type}; 434 $Declare = qr{(?:$Storage\s+(?:$Inline\s+)?)?$Type};
433} 435}
434build_types(); 436build_types();
435 437
@@ -1607,7 +1609,7 @@ sub pos_last_openparen {
1607 } 1609 }
1608 } 1610 }
1609 1611
1610 return $last_openparen + 1; 1612 return length(expand_tabs(substr($line, 0, $last_openparen))) + 1;
1611} 1613}
1612 1614
1613sub process { 1615sub process {
@@ -2200,7 +2202,7 @@ sub process {
2200 2202
2201# check multi-line statement indentation matches previous line 2203# check multi-line statement indentation matches previous line
2202 if ($^V && $^V ge 5.10.0 && 2204 if ($^V && $^V ge 5.10.0 &&
2203 $prevline =~ /^\+(\t*)(if \(|$Ident\().*(\&\&|\|\||,)\s*$/) { 2205 $prevline =~ /^\+([ \t]*)((?:$c90_Keywords(?:\s+if)\s*)|(?:$Declare\s*)?(?:$Ident|\(\s*\*\s*$Ident\s*\))\s*|$Ident\s*=\s*$Ident\s*)\(.*(\&\&|\|\||,)\s*$/) {
2204 $prevline =~ /^\+(\t*)(.*)$/; 2206 $prevline =~ /^\+(\t*)(.*)$/;
2205 my $oldindent = $1; 2207 my $oldindent = $1;
2206 my $rest = $2; 2208 my $rest = $2;