]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
lockdep: make lockdep_assert_held() not have a return value
authorJohannes Berg <johannes.berg@intel.com>
Thu, 7 Feb 2013 01:26:03 +0000 (12:26 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 18 Feb 2013 05:46:11 +0000 (16:46 +1100)
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>
include/linux/lockdep.h

index f05631effc7384566a116a79d0e79afc3c106b36..f1e877b79ed8c1f078db76daa94c207172abba22 100644 (file)
@@ -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)