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.
Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all
Unified · Split
| @@ -281,7 +281,7 @@ our $Attribute = qr{ · 280 unmodified lines | ||
| 281 | 281 | __weak |
| 282 | 282 | }x; |
| 283 | 283 | our $Modifier; |
| 284 | −our $Inline = qr{inline|__always_inline|noinline}; | |
| 284 | +our $Inline = qr{inline|__always_inline|noinline|__inline|__inline__}; | |
| 285 | 285 | our $Member = qr{->$Ident|\.$Ident|\[[^]]*\]}; |
| 286 | 286 | our $Lval = qr{$Ident(?:$Member)*}; |
| 287 | 287 | |
| @@ -304,6 +304,8 @@ our $Operators = qr{ · 16 unmodified lines | ||
| 304 | 304 | &&|\|\||,|\^|\+\+|--|&|\||$Arithmetic |
| 305 | 305 | }x; |
| 306 | 306 | |
| 307 | +our $c90_Keywords = qr{do|for|while|if|else|return|goto|continue|switch|default|case|break}x; | |
| 308 | + | |
| 307 | 309 | our $NonptrType; |
| 308 | 310 | our $NonptrTypeWithAttr; |
| 309 | 311 | our $Type; |
| @@ -429,7 +431,7 @@ sub build_types { · 119 unmodified lines | ||
| 429 | 431 | (?:(?:\s|\*|\[\])+\s*const|(?:\s|\*|\[\])+|(?:\s*\[\s*\])+)? |
| 430 | 432 | (?:\s+$Inline|\s+$Modifier)* |
| 431 | 433 | }x; |
| 432 | − $Declare = qr{(?:$Storage\s+)?$Type}; | |
| 434 | + $Declare = qr{(?:$Storage\s+(?:$Inline\s+)?)?$Type}; | |
| 433 | 435 | } |
| 434 | 436 | build_types(); |
| 435 | 437 | |
| @@ -1607,7 +1609,7 @@ sub pos_last_openparen { · 1171 unmodified lines | ||
| 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 | |
| 1613 | 1615 | sub process { |
| @@ -2200,7 +2202,7 @@ sub process { · 586 unmodified lines | ||
| 2200 | 2202 | |
| 2201 | 2203 | # check multi-line statement indentation matches previous line |
| 2202 | 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 | 2206 | $prevline =~ /^\+(\t*)(.*)$/; |
| 2205 | 2207 | my $oldindent = $1; |
| 2206 | 2208 | my $rest = $2; |