* False positive in checkpatch @ 2013-09-23 22:59 Paul E. McKenney 2013-09-24 4:21 ` Joe Perches 0 siblings, 1 reply; 6+ messages in thread From: Paul E. McKenney @ 2013-09-23 22:59 UTC (permalink / raw) To: apw, joe; +Cc: linux-kernel Hello! The checkpatch.pl script complains as follows: ERROR: need consistent spacing around '*' (ctx:WxB) #57: FILE: include/linux/rcupdate.h:564: + ACCESS_ONCE(p) = (typeof(*(v)) __force space *)(v); \ Of course, the two uses of '*' are doing different things, so it should be OK for the spacing to be different. Could you please fix this? Thanx, Paul ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: False positive in checkpatch 2013-09-23 22:59 False positive in checkpatch Paul E. McKenney @ 2013-09-24 4:21 ` Joe Perches 2013-09-24 14:03 ` Paul E. McKenney 2013-09-24 14:24 ` Andy Whitcroft 0 siblings, 2 replies; 6+ messages in thread From: Joe Perches @ 2013-09-24 4:21 UTC (permalink / raw) To: paulmck; +Cc: apw, linux-kernel On Mon, 2013-09-23 at 15:59 -0700, Paul E. McKenney wrote: > Hello! > > The checkpatch.pl script complains as follows: > > ERROR: need consistent spacing around '*' (ctx:WxB) > #57: FILE: include/linux/rcupdate.h:564: > + ACCESS_ONCE(p) = (typeof(*(v)) __force space *)(v); \ > > Of course, the two uses of '*' are doing different things, so it should > be OK for the spacing to be different. > > Could you please fix this? > > Thanx, Paul > Hi Paul. Try this patch: https://lkml.org/lkml/2013/9/2/428 Andy? Can you verify this suggested patch please? ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: False positive in checkpatch 2013-09-24 4:21 ` Joe Perches @ 2013-09-24 14:03 ` Paul E. McKenney 2013-09-24 15:13 ` Andy Whitcroft 2013-09-24 14:24 ` Andy Whitcroft 1 sibling, 1 reply; 6+ messages in thread From: Paul E. McKenney @ 2013-09-24 14:03 UTC (permalink / raw) To: Joe Perches; +Cc: apw, linux-kernel On Mon, Sep 23, 2013 at 09:21:07PM -0700, Joe Perches wrote: > On Mon, 2013-09-23 at 15:59 -0700, Paul E. McKenney wrote: > > Hello! > > > > The checkpatch.pl script complains as follows: > > > > ERROR: need consistent spacing around '*' (ctx:WxB) > > #57: FILE: include/linux/rcupdate.h:564: > > + ACCESS_ONCE(p) = (typeof(*(v)) __force space *)(v); \ > > > > Of course, the two uses of '*' are doing different things, so it should > > be OK for the spacing to be different. > > > > Could you please fix this? > > > > Thanx, Paul > > > > Hi Paul. > > Try this patch: https://lkml.org/lkml/2013/9/2/428 > > Andy? Can you verify this suggested patch please? That does it, thank you! And it does look like this patch was directed precisely at this patch. ;-) Thanx, Paul ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: False positive in checkpatch 2013-09-24 14:03 ` Paul E. McKenney @ 2013-09-24 15:13 ` Andy Whitcroft 2013-09-24 15:45 ` Paul E. McKenney 0 siblings, 1 reply; 6+ messages in thread From: Andy Whitcroft @ 2013-09-24 15:13 UTC (permalink / raw) To: Paul E. McKenney; +Cc: Joe Perches, linux-kernel On Tue, Sep 24, 2013 at 07:03:05AM -0700, Paul E. McKenney wrote: > On Mon, Sep 23, 2013 at 09:21:07PM -0700, Joe Perches wrote: > > On Mon, 2013-09-23 at 15:59 -0700, Paul E. McKenney wrote: > > > Hello! > > > > > > The checkpatch.pl script complains as follows: > > > > > > ERROR: need consistent spacing around '*' (ctx:WxB) > > > #57: FILE: include/linux/rcupdate.h:564: > > > + ACCESS_ONCE(p) = (typeof(*(v)) __force space *)(v); \ > > > > > > Of course, the two uses of '*' are doing different things, so it should > > > be OK for the spacing to be different. > > > > > > Could you please fix this? > > > > > > Thanx, Paul > > > > > > > Hi Paul. > > > > Try this patch: https://lkml.org/lkml/2013/9/2/428 > > > > Andy? Can you verify this suggested patch please? > > That does it, thank you! And it does look like this patch was directed > precisely at this patch. ;-) > > Thanx, Paul > How about this one, it is a bit of a hack but does at least correctly correct the formal characterisation of the operator to unary. Working on getting this tested a bit better before sending it out formally. -apw >From 5b4e22c123b3492838d12181129a8c168598dbf4 Mon Sep 17 00:00:00 2001 From: Andy Whitcroft <apw@canonical.com> Date: Tue, 24 Sep 2013 16:10:46 +0100 Subject: [PATCH] checkpatch: handle miss identified binary operators which bump a close parenthesis When we hit a close parenthesis, any binary operators we have without right hand sides cannot actually be binary if the code is correctly formatted. Go back and fix up any we get wrong. Signed-off-by: Andy Whitcroft <apw@canonical.com> --- scripts/checkpatch.pl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 47016c3..3d56e6e 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1277,6 +1277,16 @@ sub annotate_values { } else { print "PAREN('$1')\n" if ($dbg_values > 1); } + # Check for any pending binary operators, if they but up against this + # bracket then they are really unary, correct them. + my $pos = length($res) - 1; + while ($pos >= 0 && substr($res, $pos, 1) eq 'N') { + if (substr($var, $pos, 1) eq 'B') { + substr($var, $pos, 1) = 'U'; + print "BINARY WACKED TO UNARY at $pos\n" if ($dbg_values > 1); + } + $pos--; + } } elsif ($cur =~ /^($Ident)\s*\(/o) { print "FUNC($1)\n" if ($dbg_values > 1); @@ -1331,12 +1341,12 @@ sub annotate_values { } elsif ($cur =~ /^(-(?![->])|\+(?!\+)|\*|\&\&|\&)/o) { my $variant; - print "OPV($1)\n" if ($dbg_values > 1); if ($type eq 'V') { $variant = 'B'; } else { $variant = 'U'; } + print "OPV($1) -> $variant\n" if ($dbg_values > 1); substr($var, length($res), 1, $variant); $type = 'N'; -- 1.8.1.2 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: False positive in checkpatch 2013-09-24 15:13 ` Andy Whitcroft @ 2013-09-24 15:45 ` Paul E. McKenney 0 siblings, 0 replies; 6+ messages in thread From: Paul E. McKenney @ 2013-09-24 15:45 UTC (permalink / raw) To: Andy Whitcroft; +Cc: Joe Perches, linux-kernel On Tue, Sep 24, 2013 at 04:13:29PM +0100, Andy Whitcroft wrote: > On Tue, Sep 24, 2013 at 07:03:05AM -0700, Paul E. McKenney wrote: > > On Mon, Sep 23, 2013 at 09:21:07PM -0700, Joe Perches wrote: > > > On Mon, 2013-09-23 at 15:59 -0700, Paul E. McKenney wrote: > > > > Hello! > > > > > > > > The checkpatch.pl script complains as follows: > > > > > > > > ERROR: need consistent spacing around '*' (ctx:WxB) > > > > #57: FILE: include/linux/rcupdate.h:564: > > > > + ACCESS_ONCE(p) = (typeof(*(v)) __force space *)(v); \ > > > > > > > > Of course, the two uses of '*' are doing different things, so it should > > > > be OK for the spacing to be different. > > > > > > > > Could you please fix this? > > > > > > > > Thanx, Paul > > > > > > > > > > Hi Paul. > > > > > > Try this patch: https://lkml.org/lkml/2013/9/2/428 > > > > > > Andy? Can you verify this suggested patch please? > > > > That does it, thank you! And it does look like this patch was directed > > precisely at this patch. ;-) > > > > Thanx, Paul > > > > How about this one, it is a bit of a hack but does at least correctly > correct the formal characterisation of the operator to unary. > > Working on getting this tested a bit better before sending it out > formally. Works for me! Thanx, Paul > -apw > > > >From 5b4e22c123b3492838d12181129a8c168598dbf4 Mon Sep 17 00:00:00 2001 > From: Andy Whitcroft <apw@canonical.com> > Date: Tue, 24 Sep 2013 16:10:46 +0100 > Subject: [PATCH] checkpatch: handle miss identified binary operators which > bump a close parenthesis > > When we hit a close parenthesis, any binary operators we have without right > hand sides cannot actually be binary if the code is correctly formatted. > Go back and fix up any we get wrong. > > Signed-off-by: Andy Whitcroft <apw@canonical.com> > --- > scripts/checkpatch.pl | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index 47016c3..3d56e6e 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -1277,6 +1277,16 @@ sub annotate_values { > } else { > print "PAREN('$1')\n" if ($dbg_values > 1); > } > + # Check for any pending binary operators, if they but up against this > + # bracket then they are really unary, correct them. > + my $pos = length($res) - 1; > + while ($pos >= 0 && substr($res, $pos, 1) eq 'N') { > + if (substr($var, $pos, 1) eq 'B') { > + substr($var, $pos, 1) = 'U'; > + print "BINARY WACKED TO UNARY at $pos\n" if ($dbg_values > 1); > + } > + $pos--; > + } > > } elsif ($cur =~ /^($Ident)\s*\(/o) { > print "FUNC($1)\n" if ($dbg_values > 1); > @@ -1331,12 +1341,12 @@ sub annotate_values { > } elsif ($cur =~ /^(-(?![->])|\+(?!\+)|\*|\&\&|\&)/o) { > my $variant; > > - print "OPV($1)\n" if ($dbg_values > 1); > if ($type eq 'V') { > $variant = 'B'; > } else { > $variant = 'U'; > } > + print "OPV($1) -> $variant\n" if ($dbg_values > 1); > > substr($var, length($res), 1, $variant); > $type = 'N'; > -- > 1.8.1.2 > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: False positive in checkpatch 2013-09-24 4:21 ` Joe Perches 2013-09-24 14:03 ` Paul E. McKenney @ 2013-09-24 14:24 ` Andy Whitcroft 1 sibling, 0 replies; 6+ messages in thread From: Andy Whitcroft @ 2013-09-24 14:24 UTC (permalink / raw) To: Joe Perches; +Cc: paulmck, linux-kernel On Mon, Sep 23, 2013 at 09:21:07PM -0700, Joe Perches wrote: > On Mon, 2013-09-23 at 15:59 -0700, Paul E. McKenney wrote: > > Hello! > > > > The checkpatch.pl script complains as follows: > > > > ERROR: need consistent spacing around '*' (ctx:WxB) > > #57: FILE: include/linux/rcupdate.h:564: > > + ACCESS_ONCE(p) = (typeof(*(v)) __force space *)(v); \ > > > > Of course, the two uses of '*' are doing different things, so it should > > be OK for the spacing to be different. > > > > Could you please fix this? > > > > Thanx, Paul > > > > Hi Paul. > > Try this patch: https://lkml.org/lkml/2013/9/2/428 > > Andy? Can you verify this suggested patch please? Ok so fundamentally this goes wrong because we detect the typeof() __force part as a type, but 'space' which is a type subsituted in is not so identifiable. This leads to us identifying the '*' as a binary one. You patch prevents the error being emitted indeed, but as we have missidentified it anything else which applies to the correct type would be missed I think. I will see if I can get this to identify this form better. -apw ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-09-24 15:45 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-09-23 22:59 False positive in checkpatch Paul E. McKenney 2013-09-24 4:21 ` Joe Perches 2013-09-24 14:03 ` Paul E. McKenney 2013-09-24 15:13 ` Andy Whitcroft 2013-09-24 15:45 ` Paul E. McKenney 2013-09-24 14:24 ` Andy Whitcroft
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox