Skip to content

Commit 4a27319

Browse files
JoePerchestorvalds
authored andcommitted
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>
1 parent ce0338d commit 4a27319

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

scripts/checkpatch.pl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3313,6 +3313,22 @@ sub process {
33133313
}
33143314
}
33153315

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+
33163332
# check for new externs in .c files.
33173333
if ($realfile =~ /\.c$/ && defined $stat &&
33183334
$stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s)

0 commit comments

Comments
 (0)