]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
lockdep: Mark chain_hlock_class_idx() with __maybe_unused
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 9 Dec 2024 17:08:10 +0000 (19:08 +0200)
committerBoqun Feng <boqun.feng@gmail.com>
Thu, 19 Dec 2024 21:57:53 +0000 (13:57 -0800)
When chain_hlock_class_idx() 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:435:28: error: unused function 'chain_hlock_class_idx' [-Werror,-Wunused-function]

Fix this by marking it with __maybe_unused.

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/20241209170810.1485183-1-andriy.shevchenko@linux.intel.com
kernel/locking/lockdep.c

index 2d8ec0351ef9bd67fd3f4adf61f41dc5ecae7131..fe04a2145ca7a0c2670c6979236e526bc15c597e 100644 (file)
@@ -430,7 +430,7 @@ static inline u16 hlock_id(struct held_lock *hlock)
        return (hlock->class_idx | (hlock->read << MAX_LOCKDEP_KEYS_BITS));
 }
 
-static inline unsigned int chain_hlock_class_idx(u16 hlock_id)
+static inline __maybe_unused unsigned int chain_hlock_class_idx(u16 hlock_id)
 {
        return hlock_id & (MAX_LOCKDEP_KEYS - 1);
 }