diff options
author | Joe Perches <joe@perches.com> | 2012-07-30 17:41:20 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-07-30 20:25:17 -0400 |
commit | 4a273195a551a27a9a3ebed072c8df16c853da7f (patch) | |
tree | f6dd0354f66679adea5cab8aab0a620a6832e181 | |
parent | ce0338df3c9a43e709b8a478265b32b9edcc7ccc (diff) |
checkpatch: check usleep_range() arguments
usleep_range() shouldn't use the same args for min and max.
Report it when it happens and when both args are decimal and min > max.
Signed-off-by: Joe Perches <joe@perches.com>
Cc: Yuval Mintz <yuvalmin@broadcom.com>
Cc: Andy Whitcroft <apw@shadowen.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rwxr-xr-x | scripts/checkpatch.pl | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 3e04f80375de..4bad5700670a 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -3313,6 +3313,22 @@ sub process { | |||
3313 | } | 3313 | } |
3314 | } | 3314 | } |
3315 | 3315 | ||
3316 | # check usleep_range arguments | ||
3317 | if ($^V && $^V ge 5.10.0 && | ||
3318 | defined $stat && | ||
3319 | $stat =~ /^\+(?:.*?)\busleep_range\s*\(\s*($FuncArg)\s*,\s*($FuncArg)\s*\)/) { | ||
3320 | my $min = $1; | ||
3321 | my $max = $7; | ||
3322 | if ($min eq $max) { | ||
3323 | WARN("USLEEP_RANGE", | ||
3324 | "usleep_range should not use min == max args; see Documentation/timers/timers-howto.txt\n" . "$here\n$stat\n"); | ||
3325 | } elsif ($min =~ /^\d+$/ && $max =~ /^\d+$/ && | ||
3326 | $min > $max) { | ||
3327 | WARN("USLEEP_RANGE", | ||
3328 | "usleep_range args reversed, use min then max; see Documentation/timers/timers-howto.txt\n" . "$here\n$stat\n"); | ||
3329 | } | ||
3330 | } | ||
3331 | |||
3316 | # check for new externs in .c files. | 3332 | # check for new externs in .c files. |
3317 | if ($realfile =~ /\.c$/ && defined $stat && | 3333 | if ($realfile =~ /\.c$/ && defined $stat && |
3318 | $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s) | 3334 | $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s) |