lkml.org 
[lkml]   [2012]   [Mar]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 11/11] checkpatch: Check for spin_is_locked
Date
From: Andi Kleen <ak@linux.intel.com>

spin_is_locked is usually misued. In checkpatch.pl

- warn when it is used at all
- error out when it is asserted on free, because that's usually broken
(e.g. doesn't work on on uni processor builds). Recommend
lockdep_assert_held() instead.

Cc: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
scripts/checkpatch.pl | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index a3b9782..9904547 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3330,6 +3330,20 @@ sub process {
}
}

+# spin_is_locked is usually misused. warn about it.
+ if ($line =~ /\bspin_is_locked\s*\(/) {
+ # BUG_ON/WARN_ON(!spin_is_locked() is generally a bug
+ if ($line =~ /(BUG_ON|WARN_ON|ASSERT)\s*\(!spin_is_locked/) {
+ ERROR("ASSERT_SPIN_IS_LOCKED",
+ "Use lockdep_assert_held() instead of asserts on !spin_is_locked\n"
+ . $herecurr);
+ } else {
+ WARN("SPIN_IS_LOCKED",
+ "spin_is_locked is very rarely correctly used. Please reconsider\n"
+ . $herecurr)
+ }
+ }
+
# check for lockdep_set_novalidate_class
if ($line =~ /^.\s*lockdep_set_novalidate_class\s*\(/ ||
$line =~ /__lockdep_no_validate__\s*\)/ ) {
--
1.7.7.6


\
 
 \ /
  Last update: 2012-03-16 20:03    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site