From: Joe Perches <joe@perches.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Whitcroft <apw@canonical.com>, linux-kernel@vger.kernel.org
Subject: [PATCH 04/12] checkpatch: Warn on comparisons to jiffies
Date: Mon, 10 Jun 2013 15:20:42 -0700 [thread overview]
Message-ID: <ed5cdcf8a11e69757788c63b2f69fbecb742d750.1370902448.git.joe@perches.com> (raw)
In-Reply-To: <cover.1370902448.git.joe@perches.com>
Comparing jiffies is almost always wrong and
time_before and time_after should be used instead.
Warn on any comparison to jiffies.
Signed-off-by: Joe Perches <joe@perches.com>
---
scripts/checkpatch.pl | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 576139a..c274e1d 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3299,6 +3299,12 @@ sub process {
}
}
+# check for comparisons of jiffies
+ if ($line =~ /\bjiffies\s*$Compare|$Compare\s*jiffies\b/) {
+ WARN("JIFFIES_COMPARISON",
+ "Comparing jiffies is almost always wrong; prefer time_after, time_before and friends\n" . $herecurr);
+ }
+
# warn about #ifdefs in C files
# if ($line =~ /^.\s*\#\s*if(|n)def/ && ($realfile =~ /\.c$/)) {
# print "#ifdef in C files should be avoided\n";
--
1.8.1.2.459.gbcd45b4.dirty
next prev parent reply other threads:[~2013-06-10 22:21 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-10 22:20 [PATCH 00/12] checkpatch: collection of neatenings and new "--fix" Joe Perches
2013-06-10 22:20 ` [PATCH 01/12] checkpatch: Remove quote from CamelCase test Joe Perches
2013-06-10 22:20 ` [PATCH 02/12] checkpatch: Improve network block comment test and message Joe Perches
2013-06-10 22:20 ` [PATCH 03/12] checkpatch: Warn when networking block comment lines don't start with * Joe Perches
2013-06-10 22:20 ` Joe Perches [this message]
2013-06-10 22:20 ` [PATCH 05/12] checkpatch: Warn on comparisons to get_jiffies_64() Joe Perches
2013-06-10 22:20 ` [PATCH 06/12] checkpatch: Reduce false positive rate of "complex macros" Joe Perches
2013-06-10 22:20 ` [PATCH 07/12] checkpatch: Add a placeholder to check blank lines before declarations Joe Perches
2013-06-10 22:20 ` [PATCH 08/12] checkpatch: Don't warn on blank lines before/after braces as often Joe Perches
2013-06-10 22:20 ` [PATCH 09/12] checkpatch: Add a --strict test for comparison to true/false Joe Perches
2013-06-10 22:20 ` [PATCH 10/12] checkpatch: Improve "no space after cast" test Joe Perches
2013-06-10 22:20 ` [PATCH 11/12] checkpatch: Create an EXPERIMENTAL --fix option to correct patches Joe Perches
2013-06-10 22:20 ` [PATCH 12/12] checkpatch: Move test for space before semicolon after operator spacing Joe Perches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ed5cdcf8a11e69757788c63b2f69fbecb742d750.1370902448.git.joe@perches.com \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=apw@canonical.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®