Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 259020
b: refs/heads/master
c: 7d2367a
h: refs/heads/master
v: v3
  • Loading branch information
Joe Perches authored and Linus Torvalds committed Jul 26, 2011
1 parent d24fadc commit be78038
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 27c46a2546c75c6814562e85b751e3d64c188ad5
refs/heads/master: 7d2367af0b09f8028dc5c1b1919bb82d141c2afb
35 changes: 35 additions & 0 deletions trunk/scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,20 @@ sub build_types {
}
build_types();

our $match_balanced_parentheses = qr/(\((?:[^\(\)]+|(-1))*\))/;

our $Typecast = qr{\s*(\(\s*$NonptrType\s*\)){0,1}\s*};
our $LvalOrFunc = qr{($Lval)\s*($match_balanced_parentheses{0,1})\s*};

sub deparenthesize {
my ($string) = @_;
return "" if (!defined($string));
$string =~ s@^\s*\(\s*@@g;
$string =~ s@\s*\)\s*$@@g;
$string =~ s@\s+@ @g;
return $string;
}

$chk_signoff = 0 if ($file);

my @dep_includes = ();
Expand Down Expand Up @@ -2290,6 +2304,27 @@ sub process {
}
}

# typecasts on min/max could be min_t/max_t
if ($line =~ /^\+(?:.*?)\b(min|max)\s*\($Typecast{0,1}($LvalOrFunc)\s*,\s*$Typecast{0,1}($LvalOrFunc)\s*\)/) {
if (defined $2 || defined $8) {
my $call = $1;
my $cast1 = deparenthesize($2);
my $arg1 = $3;
my $cast2 = deparenthesize($8);
my $arg2 = $9;
my $cast;

if ($cast1 ne "" && $cast2 ne "") {
$cast = "$cast1 or $cast2";
} elsif ($cast1 ne "") {
$cast = $cast1;
} else {
$cast = $cast2;
}
WARN("$call() should probably be ${call}_t($cast, $arg1, $arg2)\n" . $herecurr);
}
}

# Need a space before open parenthesis after if, while etc
if ($line=~/\b(if|while|for|switch)\(/) {
ERROR("space required before the open parenthesis '('\n" . $herecurr);
Expand Down

0 comments on commit be78038

Please sign in to comment.