Skip to content

Commit

Permalink
checkpatch: warn about unexpectedly long msleep's
Browse files Browse the repository at this point in the history
As explained in Documentation/timers/timers-howto.txt, msleep's of < 20ms
may sleep for as long as 20ms.  Caller's of msleep(1) or msleep(2), etc
are likely not to expect this quirky behavior - warn them.

Signed-off-by: Patrick Pannuto <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Patrick Pannuto authored and torvalds committed Aug 10, 2010
1 parent 1a15a25 commit 09ef872
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2592,6 +2592,13 @@ sub process {
}
}

# warn about unexpectedly long msleep's
if ($line =~ /\bmsleep\s*\((\d+)\);/) {
if ($1 < 20) {
WARN("msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt\n" . $line);
}
}

# warn about #ifdefs in C files
# if ($line =~ /^.\s*\#\s*if(|n)def/ && ($realfile =~ /\.c$/)) {
# print "#ifdef in C files should be avoided\n";
Expand Down

0 comments on commit 09ef872

Please sign in to comment.