* [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
* [PATCH 2/2] checkpatch: Don't warn on bitfield spaces around :
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 ` 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
1 sibling, 1 reply; 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
This test prevents code from being aligned around the :
for easy visual counting of bitfield lengths.
ie:
int foo : 1,
int bar : 2,
int foobar :29;
should be acceptable so remove the test.
Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Joe Perches <joe@perches.com>
---
scripts/checkpatch.pl | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index ac0169c..70c932b 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3153,10 +3153,13 @@ sub process {
# // is a comment
} elsif ($op eq '//') {
+ # : when part of a bitfield
+ } elsif ($opv eq ':B') {
+ # skip the bitfield test for now
+
# No spaces for:
# ->
- # : when part of a bitfield
- } elsif ($op eq '->' || $opv eq ':B') {
+ } elsif ($op eq '->') {
if ($ctx =~ /Wx.|.xW/) {
if (ERROR("SPACING",
"spaces prohibited around that '$op' $at\n" . $hereptr)) {
--
1.8.1.2.459.gbcd45b4.dirty
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH V2 1/2] checkpatch: Expand parenthesis alignment test to declarations, functions and assignments
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-03-31 22:06 ` Andrew Morton
2014-03-31 22:10 ` Joe Perches
1 sibling, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2014-03-31 22:06 UTC (permalink / raw)
To: Joe Perches; +Cc: Dan Carpenter, Andy Whitcroft, linux-kernel
On Mon, 31 Mar 2014 14:58:07 -0700 Joe Perches <joe@perches.com> wrote:
> 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>".
I'm having trouble understanding what this patch actually does. Some
little examples would be nice.
I typed in this to play with:
void foo(int a,
int b)
{
}
but I experienced playus interruptus
akpm3:/usr/src/25> perl scripts/checkpatch.pl -f t.c
Global symbol "$c90_Keywords" requires explicit package name at scripts/checkpatch.pl line 2162.
Execution of scripts/checkpatch.pl aborted due to compilation errors.
System is Ubuntu 12.04.4 (ish).
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH V2 1/2] checkpatch: Expand parenthesis alignment test to declarations, functions and assignments
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
0 siblings, 1 reply; 6+ messages in thread
From: Joe Perches @ 2014-03-31 22:10 UTC (permalink / raw)
To: Andrew Morton; +Cc: Dan Carpenter, Andy Whitcroft, linux-kernel
On Mon, 2014-03-31 at 15:06 -0700, Andrew Morton wrote:
> On Mon, 31 Mar 2014 14:58:07 -0700 Joe Perches <joe@perches.com> wrote:
>
> > 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>".
>
> I'm having trouble understanding what this patch actually does. Some
> little examples would be nice.
>
> I typed in this to play with:
>
> void foo(int a,
> int b)
> {
> }
>
> but I experienced playus interruptus
>
> akpm3:/usr/src/25> perl scripts/checkpatch.pl -f t.c
> Global symbol "$c90_Keywords" requires explicit package name at scripts/checkpatch.pl line 2162.
> Execution of scripts/checkpatch.pl aborted due to compilation errors.
>
> System is Ubuntu 12.04.4 (ish).
You have to apply it to -next (your mm queue)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH V2 1/2] checkpatch: Expand parenthesis alignment test to declarations, functions and assignments
2014-03-31 22:10 ` Joe Perches
@ 2014-03-31 22:19 ` Andrew Morton
0 siblings, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2014-03-31 22:19 UTC (permalink / raw)
To: Joe Perches; +Cc: Dan Carpenter, Andy Whitcroft, linux-kernel
On Mon, 31 Mar 2014 15:10:38 -0700 Joe Perches <joe@perches.com> wrote:
> On Mon, 2014-03-31 at 15:06 -0700, Andrew Morton wrote:
> > On Mon, 31 Mar 2014 14:58:07 -0700 Joe Perches <joe@perches.com> wrote:
> >
> > > 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>".
> >
> > I'm having trouble understanding what this patch actually does. Some
> > little examples would be nice.
?
> > I typed in this to play with:
> >
> > void foo(int a,
> > int b)
> > {
> > }
> >
> > but I experienced playus interruptus
> >
> > akpm3:/usr/src/25> perl scripts/checkpatch.pl -f t.c
> > Global symbol "$c90_Keywords" requires explicit package name at scripts/checkpatch.pl line 2162.
> > Execution of scripts/checkpatch.pl aborted due to compilation errors.
> >
> > System is Ubuntu 12.04.4 (ish).
>
> You have to apply it to -next (your mm queue)
OK, the magic line was provided by
checkpatch-reduce-false-positives-for-missing-blank-line-after-declarations-test.patch,
which is marked "maybe merge, after I've played with it a bit". I'll move
that hunk into
checkpatch-expand-parenthesis-alignment-test-to-declarations-functions-and-assignments.patch
--- a/scripts/checkpatch.pl~checkpatch-expand-parenthesis-alignment-test-to-declarations-functions-and-assignments-fix
+++ a/scripts/checkpatch.pl
@@ -304,6 +304,8 @@ our $Operators = qr{
&&|\|\||,|\^|\+\+|--|&|\||$Arithmetic
}x;
+our $c90_Keywords = qr{do|for|while|if|else|return|goto|continue|switch|default|case|break}x;
+
our $NonptrType;
our $NonptrTypeWithAttr;
our $Type;
_
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] checkpatch: Don't warn on bitfield spaces around :
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
0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2014-04-01 11:42 UTC (permalink / raw)
To: Joe Perches; +Cc: Andrew Morton, Andy Whitcroft, linux-kernel
Thanks, Joe.
regards,
dan carpenter
^ permalink raw reply [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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.