public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2 1/2] checkpatch: Expand parenthesis alignment test to declarations, functions and assignments
@ 2014-03-31 21:58 Joe Perches
  2014-03-31 21:58 ` [PATCH 2/2] checkpatch: Don't warn on bitfield spaces around : Joe Perches
  2014-03-31 22:06 ` [PATCH V2 1/2] checkpatch: Expand parenthesis alignment test to declarations, functions and assignments Andrew Morton
  0 siblings, 2 replies; 6+ messages in thread
From: Joe Perches @ 2014-03-31 21:58 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Dan Carpenter, Andy Whitcroft, linux-kernel

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>".

Signed-off-by: Joe Perches <joe@perches.com>
---
V2: Fix return style of pos_last_openparen

 scripts/checkpatch.pl | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 889929d..ac0169c 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -281,7 +281,7 @@ our $Attribute	= qr{
 			__weak
 		  }x;
 our $Modifier;
-our $Inline	= qr{inline|__always_inline|noinline};
+our $Inline	= qr{inline|__always_inline|noinline|__inline|__inline__};
 our $Member	= qr{->$Ident|\.$Ident|\[[^]]*\]};
 our $Lval	= qr{$Ident(?:$Member)*};
 
@@ -435,7 +435,7 @@ sub build_types {
 			(?:(?:\s|\*|\[\])+\s*const|(?:\s|\*|\[\])+|(?:\s*\[\s*\])+)?
 			(?:\s+$Inline|\s+$Modifier)*
 		  }x;
-	$Declare	= qr{(?:$Storage\s+)?$Type};
+	$Declare	= qr{(?:$Storage\s+(?:$Inline\s+)?)?$Type};
 }
 build_types();
 
@@ -1613,7 +1613,7 @@ sub pos_last_openparen {
 		}
 	}
 
-	return $last_openparen + 1;
+	return length(expand_tabs(substr($line, 0, $last_openparen))) + 1;
 }
 
 sub process {
@@ -2200,7 +2200,7 @@ sub process {
 
 # check multi-line statement indentation matches previous line
 		if ($^V && $^V ge 5.10.0 &&
-		    $prevline =~ /^\+(\t*)(if \(|$Ident\().*(\&\&|\|\||,)\s*$/) {
+		    $prevline =~ /^\+([ \t]*)((?:$c90_Keywords(?:\s+if)\s*)|(?:$Declare\s*)?(?:$Ident|\(\s*\*\s*$Ident\s*\))\s*|$Ident\s*=\s*$Ident\s*)\(.*(\&\&|\|\||,)\s*$/) {
 			$prevline =~ /^\+(\t*)(.*)$/;
 			my $oldindent = $1;
 			my $rest = $2;
-- 
1.8.1.2.459.gbcd45b4.dirty


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-04-01 11:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-31 21:58 [PATCH V2 1/2] checkpatch: Expand parenthesis alignment test to declarations, functions and assignments Joe Perches
2014-03-31 21:58 ` [PATCH 2/2] checkpatch: Don't warn on bitfield spaces around : Joe Perches
2014-04-01 11:42   ` Dan Carpenter
2014-03-31 22:06 ` [PATCH V2 1/2] checkpatch: Expand parenthesis alignment test to declarations, functions and assignments Andrew Morton
2014-03-31 22:10   ` Joe Perches
2014-03-31 22:19     ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox