From: Johannes Berg Date: Wed, 20 Feb 2013 02:13:51 +0000 (+1100) Subject: lockdep: make lockdep_assert_held() not have a return value X-Git-Tag: next-20130220~1^2~615 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=250cff7d6aabf3fd44cabcaaec555e1b8e63533b;p=karo-tx-linux.git 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 Cc: Peter Zijlstra Cc: Ingo Molnar Signed-off-by: Andrew Morton --- diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index f05631effc73..f1e877b79ed8 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)