[PATCH] checkpatch: handle miss identified binary operators whichbump a close parenthesis

From: Andy Whitcroft
Date: Tue Sep 24 2013 - 11:10:46 EST


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@xxxxxxxxxxxxx>
---
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/