Commit 4a273195 authored by Joe Perches's avatar Joe Perches Committed by Linus Torvalds

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: default avatarJoe Perches <joe@perches.com>
Cc: Yuval Mintz <yuvalmin@broadcom.com>
Cc: Andy Whitcroft <apw@shadowen.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ce0338df
...@@ -3313,6 +3313,22 @@ sub process { ...@@ -3313,6 +3313,22 @@ sub process {
} }
} }
# check usleep_range arguments
if ($^V && $^V ge 5.10.0 &&
defined $stat &&
$stat =~ /^\+(?:.*?)\busleep_range\s*\(\s*($FuncArg)\s*,\s*($FuncArg)\s*\)/) {
my $min = $1;
my $max = $7;
if ($min eq $max) {
WARN("USLEEP_RANGE",
"usleep_range should not use min == max args; see Documentation/timers/timers-howto.txt\n" . "$here\n$stat\n");
} elsif ($min =~ /^\d+$/ && $max =~ /^\d+$/ &&
$min > $max) {
WARN("USLEEP_RANGE",
"usleep_range args reversed, use min then max; see Documentation/timers/timers-howto.txt\n" . "$here\n$stat\n");
}
}
# check for new externs in .c files. # check for new externs in .c files.
if ($realfile =~ /\.c$/ && defined $stat && if ($realfile =~ /\.c$/ && defined $stat &&
$stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s) $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment