]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
lockdep: Move lockdep_assert_locked() under #ifdef CONFIG_PROVE_LOCKING
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 2 Dec 2024 19:34:45 +0000 (21:34 +0200)
committerBoqun Feng <boqun.feng@gmail.com>
Thu, 19 Dec 2024 22:04:03 +0000 (14:04 -0800)
When lockdep_assert_locked() is unused, it prevents kernel builds
with clang, `make W=1` and CONFIG_WERROR=y, CONFIG_LOCKDEP=y and
CONFIG_PROVE_LOCKING=n:

  kernel/locking/lockdep.c:160:20: error: unused function 'lockdep_assert_locked' [-Werror,-Wunused-function]

Fix this by moving it under the respective ifdeffery.

See also commit 6863f5643dd7 ("kbuild: allow Clang to find unused static
inline functions for W=1 build").

[Boqun: add more config information of the error]

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://lore.kernel.org/r/20241202193445.769567-1-andriy.shevchenko@linux.intel.com
kernel/locking/lockdep.c

index fe04a2145ca7a0c2670c6979236e526bc15c597e..29acd238dad703e75b0657908b70a54cf8fb1c7f 100644 (file)
@@ -157,10 +157,12 @@ static inline void lockdep_unlock(void)
        __this_cpu_dec(lockdep_recursion);
 }
 
+#ifdef CONFIG_PROVE_LOCKING
 static inline bool lockdep_assert_locked(void)
 {
        return DEBUG_LOCKS_WARN_ON(__owner != current);
 }
+#endif
 
 static struct task_struct *lockdep_selftest_task_struct;