summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/checkpatch.pl35
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b0aa2c680593..5ba62d8b5e52 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -268,6 +268,20 @@ sub build_types {
268} 268}
269build_types(); 269build_types();
270 270
271our $match_balanced_parentheses = qr/(\((?:[^\(\)]+|(-1))*\))/;
272
273our $Typecast = qr{\s*(\(\s*$NonptrType\s*\)){0,1}\s*};
274our $LvalOrFunc = qr{($Lval)\s*($match_balanced_parentheses{0,1})\s*};
275
276sub deparenthesize {
277 my ($string) = @_;
278 return "" if (!defined($string));
279 $string =~ s@^\s*\(\s*@@g;
280 $string =~ s@\s*\)\s*$@@g;
281 $string =~ s@\s+@ @g;
282 return $string;
283}
284
271$chk_signoff = 0 if ($file); 285$chk_signoff = 0 if ($file);
272 286
273my @dep_includes = (); 287my @dep_includes = ();
@@ -2290,6 +2304,27 @@ sub process {
2290 } 2304 }
2291 } 2305 }
2292 2306
2307# typecasts on min/max could be min_t/max_t
2308 if ($line =~ /^\+(?:.*?)\b(min|max)\s*\($Typecast{0,1}($LvalOrFunc)\s*,\s*$Typecast{0,1}($LvalOrFunc)\s*\)/) {
2309 if (defined $2 || defined $8) {
2310 my $call = $1;
2311 my $cast1 = deparenthesize($2);
2312 my $arg1 = $3;
2313 my $cast2 = deparenthesize($8);
2314 my $arg2 = $9;
2315 my $cast;
2316
2317 if ($cast1 ne "" && $cast2 ne "") {
2318 $cast = "$cast1 or $cast2";
2319 } elsif ($cast1 ne "") {
2320 $cast = $cast1;
2321 } else {
2322 $cast = $cast2;
2323 }
2324 WARN("$call() should probably be ${call}_t($cast, $arg1, $arg2)\n" . $herecurr);
2325 }
2326 }
2327
2293# Need a space before open parenthesis after if, while etc 2328# Need a space before open parenthesis after if, while etc
2294 if ($line=~/\b(if|while|for|switch)\(/) { 2329 if ($line=~/\b(if|while|for|switch)\(/) {
2295 ERROR("space required before the open parenthesis '('\n" . $herecurr); 2330 ERROR("space required before the open parenthesis '('\n" . $herecurr);