aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/checkpatch.pl46
1 files changed, 32 insertions, 14 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 45a97c9f4c9b..850783674278 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -191,7 +191,7 @@ sub build_types {
191 }x; 191 }x;
192 $Type = qr{ 192 $Type = qr{
193 $NonptrType 193 $NonptrType
194 (?:\s*\*+\s*const|\s*\*+|(?:\s*\[\s*\])+)? 194 (?:[\s\*]+\s*const|[\s\*]+|(?:\s*\[\s*\])+)?
195 (?:\s+$Inline|\s+$Modifier)* 195 (?:\s+$Inline|\s+$Modifier)*
196 }x; 196 }x;
197 $Declare = qr{(?:$Storage\s+)?$Type}; 197 $Declare = qr{(?:$Storage\s+)?$Type};
@@ -1344,7 +1344,7 @@ sub process {
1344 } 1344 }
1345 1345
1346 # any (foo ... *) is a pointer cast, and foo is a type 1346 # any (foo ... *) is a pointer cast, and foo is a type
1347 while ($s =~ /\(($Ident)(?:\s+$Sparse)*\s*\*+\s*\)/sg) { 1347 while ($s =~ /\(($Ident)(?:\s+$Sparse)*[\s\*]+\s*\)/sg) {
1348 possible($1, "C:" . $s); 1348 possible($1, "C:" . $s);
1349 } 1349 }
1350 1350
@@ -1618,21 +1618,39 @@ sub process {
1618 } 1618 }
1619 1619
1620# * goes on variable not on type 1620# * goes on variable not on type
1621 if ($line =~ m{\($NonptrType(\*+)(?:\s+const)?\)}) { 1621 # (char*[ const])
1622 ERROR("\"(foo$1)\" should be \"(foo $1)\"\n" . 1622 if ($line =~ m{\($NonptrType(\s*\*[\s\*]*(?:$Modifier\s*)*)\)}) {
1623 $herecurr); 1623 my ($from, $to) = ($1, $1);
1624 1624
1625 } elsif ($line =~ m{\($NonptrType\s+(\*+)(?!\s+const)\s+\)}) { 1625 # Should start with a space.
1626 ERROR("\"(foo $1 )\" should be \"(foo $1)\"\n" . 1626 $to =~ s/^(\S)/ $1/;
1627 $herecurr); 1627 # Should not end with a space.
1628 $to =~ s/\s+$//;
1629 # '*'s should not have spaces between.
1630 while ($to =~ s/(.)\s\*/$1\*/) {
1631 }
1628 1632
1629 } elsif ($line =~ m{\b$NonptrType(\*+)(?:\s+(?:$Attribute|$Sparse))?\s+[A-Za-z\d_]+}) { 1633 #print "from<$from> to<$to>\n";
1630 ERROR("\"foo$1 bar\" should be \"foo $1bar\"\n" . 1634 if ($from ne $to) {
1631 $herecurr); 1635 ERROR("\"(foo$from)\" should be \"(foo$to)\"\n" . $herecurr);
1636 }
1637 } elsif ($line =~ m{\b$NonptrType(\s*\*[\s\*]*(?:$Modifier\s*)?)($Ident)}) {
1638 my ($from, $to, $ident) = ($1, $1, $2);
1632 1639
1633 } elsif ($line =~ m{\b$NonptrType\s+(\*+)(?!\s+(?:$Attribute|$Sparse))\s+[A-Za-z\d_]+}) { 1640 # Should start with a space.
1634 ERROR("\"foo $1 bar\" should be \"foo $1bar\"\n" . 1641 $to =~ s/^(\S)/ $1/;
1635 $herecurr); 1642 # Should not end with a space.
1643 $to =~ s/\s+$//;
1644 # '*'s should not have spaces between.
1645 while ($to =~ s/(.)\s\*/$1\*/) {
1646 }
1647 # Modifiers should have spaces.
1648 $to =~ s/(\b$Modifier$)/$1 /;
1649
1650 #print "from<$from> to<$to>\n";
1651 if ($from ne $to) {
1652 ERROR("\"foo${from}bar\" should be \"foo${to}bar\"\n" . $herecurr);
1653 }
1636 } 1654 }
1637 1655
1638# # no BUG() or BUG_ON() 1656# # no BUG() or BUG_ON()