aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorAndy Whitcroft <apw@shadowen.org>2008-07-24 00:29:10 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-24 13:47:26 -0400
commit74048ed811152a995a88945ba9e0dded34adfff4 (patch)
tree6a129872a995f6fe24d02f3754ec50b69a6bd3f6 /scripts
parent1f65f947a6a875e1fe7867dc08e981c4101d435d (diff)
checkpatch: variants -- move the main unary/binary operators to use variants
Now that we have a variants system, move to using that to carry the unary/binary designation for +, -, &, and *. Signed-off-by: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkpatch.pl36
1 files changed, 18 insertions, 18 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 88027f237cdf..8afa88aaed96 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -858,6 +858,19 @@ sub annotate_values {
858 print "CLOSE($1)\n" if ($dbg_values > 1); 858 print "CLOSE($1)\n" if ($dbg_values > 1);
859 $type = 'N'; 859 $type = 'N';
860 860
861 } elsif ($cur =~ /^(-(?![->])|\+(?!\+)|\*|\&(?!\&))/o) {
862 my $variant;
863
864 print "OPV($1)\n" if ($dbg_values > 1);
865 if ($type eq 'V') {
866 $variant = 'B';
867 } else {
868 $variant = 'U';
869 }
870
871 substr($var, length($res), 1, $variant);
872 $type = 'N';
873
861 } elsif ($cur =~ /^($Operators)/o) { 874 } elsif ($cur =~ /^($Operators)/o) {
862 print "OP($1)\n" if ($dbg_values > 1); 875 print "OP($1)\n" if ($dbg_values > 1);
863 if ($1 ne '++' && $1 ne '--') { 876 if ($1 ne '++' && $1 ne '--') {
@@ -1573,22 +1586,8 @@ sub process {
1573 my $ptr = substr($blank, 0, $off) . "^"; 1586 my $ptr = substr($blank, 0, $off) . "^";
1574 my $hereptr = "$hereline$ptr\n"; 1587 my $hereptr = "$hereline$ptr\n";
1575 1588
1576 # Classify operators into binary, unary, or 1589 # Pull out the value of this operator.
1577 # definitions (* only) where they have more
1578 # than one mode.
1579 my $op_type = substr($curr_values, $off + 1, 1); 1590 my $op_type = substr($curr_values, $off + 1, 1);
1580 my $op_left = substr($curr_values, $off, 1);
1581 my $is_unary;
1582 if ($op_type eq 'T') {
1583 $is_unary = 2;
1584 } elsif ($op_left eq 'V') {
1585 $is_unary = 0;
1586 } else {
1587 $is_unary = 1;
1588 }
1589 #if ($op eq '-' || $op eq '&' || $op eq '*') {
1590 # print "UNARY: <$op_left$op_type $is_unary $a:$op:$c> <$ca:$op:$cc> <$unary_ctx>\n";
1591 #}
1592 1591
1593 # Get the full operator variant. 1592 # Get the full operator variant.
1594 my $opv = $op . substr($curr_vars, $off, 1); 1593 my $opv = $op . substr($curr_vars, $off, 1);
@@ -1625,18 +1624,19 @@ sub process {
1625 } 1624 }
1626 1625
1627 # '*' as part of a type definition -- reported already. 1626 # '*' as part of a type definition -- reported already.
1628 } elsif ($op eq '*' && $is_unary == 2) { 1627 } elsif ($opv eq '*_') {
1629 #warn "'*' is part of type\n"; 1628 #warn "'*' is part of type\n";
1630 1629
1631 # unary operators should have a space before and 1630 # unary operators should have a space before and
1632 # none after. May be left adjacent to another 1631 # none after. May be left adjacent to another
1633 # unary operator, or a cast 1632 # unary operator, or a cast
1634 } elsif ($op eq '!' || $op eq '~' || 1633 } elsif ($op eq '!' || $op eq '~' ||
1635 ($is_unary && ($op eq '*' || $op eq '-' || $op eq '&'))) { 1634 $opv eq '*U' || $opv eq '-U' ||
1635 $opv eq '&U') {
1636 if ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) { 1636 if ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) {
1637 ERROR("space required before that '$op' $at\n" . $hereptr); 1637 ERROR("space required before that '$op' $at\n" . $hereptr);
1638 } 1638 }
1639 if ($op eq '*' && $cc =~/\s*const\b/) { 1639 if ($op eq '*' && $cc =~/\s*const\b/) {
1640 # A unary '*' may be const 1640 # A unary '*' may be const
1641 1641
1642 } elsif ($ctx =~ /.xW/) { 1642 } elsif ($ctx =~ /.xW/) {