Commit 74048ed811152a995a88945ba9e0dded34adfff4

Authored by Andy Whitcroft
Committed by Linus Torvalds
1 parent 1f65f947a6

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>

Showing 1 changed file with 18 additions and 18 deletions Side-by-side Diff

scripts/checkpatch.pl
... ... @@ -858,6 +858,19 @@
858 858 print "CLOSE($1)\n" if ($dbg_values > 1);
859 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 874 } elsif ($cur =~ /^($Operators)/o) {
862 875 print "OP($1)\n" if ($dbg_values > 1);
863 876 if ($1 ne '++' && $1 ne '--') {
864 877  
... ... @@ -1573,22 +1586,8 @@
1573 1586 my $ptr = substr($blank, 0, $off) . "^";
1574 1587 my $hereptr = "$hereline$ptr\n";
1575 1588  
1576   - # Classify operators into binary, unary, or
1577   - # definitions (* only) where they have more
1578   - # than one mode.
  1589 + # Pull out the value of this operator.
1579 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 1592 # Get the full operator variant.
1594 1593 my $opv = $op . substr($curr_vars, $off, 1);
1595 1594  
1596 1595  
... ... @@ -1625,18 +1624,19 @@
1625 1624 }
1626 1625  
1627 1626 # '*' as part of a type definition -- reported already.
1628   - } elsif ($op eq '*' && $is_unary == 2) {
  1627 + } elsif ($opv eq '*_') {
1629 1628 #warn "'*' is part of type\n";
1630 1629  
1631 1630 # unary operators should have a space before and
1632 1631 # none after. May be left adjacent to another
1633 1632 # unary operator, or a cast
1634 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 1636 if ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) {
1637 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 1640 # A unary '*' may be const
1641 1641  
1642 1642 } elsif ($ctx =~ /.xW/) {