path: root/include/linux/lockdep.h
diff options
authorJohannes Berg <johannes.berg@intel.com>2013-02-21 16:42:47 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-21 17:22:19 -0800
commitb1ae345d971664f70cfdc293029c40ccfb093591 (patch)
treedcc1e4e8aed9da51a87eca71a8b133a001487381 /include/linux/lockdep.h
parent3278bb748d2437eb1464765f36429e5d6aa91c38 (diff)
lockdep: make lockdep_assert_held() not have a return value
I recently made the mistake of writing: foo = lockdep_dereference_protected(..., lockdep_assert_held(...)); which is clearly bogus. If lockdep is disabled in the config this would cause a compile failure, if it is enabled then it compiles and causes a puzzling warning about dereferencing without the correct protection. Wrap the macro in "do { ... } while (0)" to also fail compile for this when lockdep is enabled. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ingo Molnar <mingo@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/lockdep.h')
1 files changed, 3 insertions, 1 deletions
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index 2bca44b0893..bfe88c4aa25 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -359,7 +359,9 @@ extern void lockdep_trace_alloc(gfp_t mask);
#define lockdep_depth(tsk) (debug_locks ? (tsk)->lockdep_depth : 0)
-#define lockdep_assert_held(l) WARN_ON(debug_locks && !lockdep_is_held(l))
+#define lockdep_assert_held(l) do { \
+ WARN_ON(debug_locks && !lockdep_is_held(l)); \
+ } while (0)
#define lockdep_recursing(tsk) ((tsk)->lockdep_recursion)