Skip to contentSkip to conversation

lockdep: fix warning: print_lock_trace defined but not used

PATCH New John Hubbard 1 participant 2 messages May 19, 2019 Locking primitives

lore
Share & tools
lore
#0 lore raw

cover lockdep: fix warning: print_lock_trace defined but not used

Hi,

I ran across this minor warning while building against today's linux.git.

The proposed trivial fix leaves it a little fragile from a "what if someone adds a new call to print_lock_trace()" point of view, but I believe that it makes the current combination of ifdefs accurate, anyway.

Cc Frederic Weisbecker <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Paul E. McKenney <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Will Deacon <[email protected]>

John Hubbard (1):
lockdep: fix warning: print_lock_trace defined but not used

 kernel/locking/lockdep.c | 3 +++
 1 file changed, 3 insertions(+)
Signature · 1 line
2.21.0
#1 lore raw

PATCH 1/1 lockdep: fix warning: print_lock_trace defined but not used

Commit 0d2cc3b34532 ("locking/lockdep: Move valid_state() inside CONFIG_TRACE_IRQFLAGS && CONFIG_PROVE_LOCKING") moved the only usage of print_lock_trace() that was originally outside of the CONFIG_PROVE_LOCKING case. It moved that usage into a different case: CONFIG_PROVE_LOCKING && CONFIG_TRACE_IRQFLAGS. That leaves things not symmetrical, and as a result, the following warning fires on my build, when I have

!CONFIG_TRACE_IRQFLAGS && !CONFIG_PROVE_LOCKING

set:

kernel/locking/lockdep.c:2821:13: warning: ‘print_lock_trace’ defined
but not used [-Wunused-function]

Fix this by only defining print_lock_trace() in cases in which is it called.

Fixes 0d2cc3b34532 ("locking/lockdep: Move valid_state() inside CONFIG_TRACE_IRQFLAGS && CONFIG_PROVE_LOCKING")
Cc Frederic Weisbecker <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Paul E. McKenney <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Will Deacon <[email protected]>
---
 kernel/locking/lockdep.c | 3 +++
 1 file changed, 3 insertions(+)
kernel/locking/lockdep.c +3 -0
index d06190fa5082..3065dc36c27a 100644
@@ -2817,11 +2817,14 @@ static inline int validate_chain(struct task_struct *curr,
 	return 1;
 }
 
+#if defined(CONFIG_TRACE_IRQFLAGS)
 static void print_lock_trace(struct lock_trace *trace, unsigned int spaces)
 {
 }
 #endif
 
+#endif
+
 /*
  * We are building curr_chain_key incrementally, so double-check
  * it from scratch, to make sure that it's done correctly:
Signature · 1 line
2.21.0