Skip to contentSkip to conversation

tracing: hide unused functions

PATCH In review Arnd Bergmann 2 participants 3 messages Oct 13, 2017 Tracing

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tracing: hide unused functions

After trace_selftest_startup_sched_switch is removed, trace_test_buffer() is now only used inside of CONFIG_FUNCTION_TRACER, leading to this warning:

kernel/trace/trace_selftest.c:62:12: error: 'trace_test_buffer' defined but not used [-Werror=unused-function]

The same is true for a few other functions called by trace_test_buffer(), so let's extend the #ifdef to cover all of them together.

Fixes d8c4deee6dc6 ("tracing: Remove obsolete sched_switch tracer selftest")
---
 kernel/trace/trace_selftest.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/trace/trace_selftest.c +2 -1
index 364f78abdf47..bcdffeca9bd8 100644
@@ -6,6 +6,8 @@
 #include <linux/delay.h>
 #include <linux/slab.h>
 
+#ifdef CONFIG_FUNCTION_TRACER
+
 static inline int trace_valid_entry(struct trace_entry *entry)
 {
 	switch (entry->type) {
@@ -98,7 +100,6 @@ static inline void warn_failed_init_tracer(struct tracer *trace, int init_ret)
 	printk(KERN_WARNING "Failed to init %s tracer, init returned %d\n",
 		trace->name, init_ret);
 }
-#ifdef CONFIG_FUNCTION_TRACER
 
 #ifdef CONFIG_DYNAMIC_FTRACE
 
Signature · 1 line
2.9.0
#1 lore raw
Quoted 11 lines · Arnd Bergmann

After trace_selftest_startup_sched_switch is removed, trace_test_buffer() is now only used inside of CONFIG_FUNCTION_TRACER, leading to this warning:

kernel/trace/trace_selftest.c:62:12: error: 'trace_test_buffer' defined but not used [-Werror=unused-function]

The same is true for a few other functions called by trace_test_buffer(), so let's extend the #ifdef to cover all of them together.

Fixes d8c4deee6dc6 ("tracing: Remove obsolete sched_switch tracer selftest")

Nevermind, I ran into another problem with this applied: trace_test_buffer() is used elsewhere after all, just not for all possible combinations.

Maybe marking it as __maybe_unused would be more appropriate?

Arnd

maintainer
#2 lore raw
Quoted 10 lines · On Fri, 13 Oct 2017 15:02:34 +0200 Arnd Bergmann <[email protected]> wrote:
Quoted 9 lines · Arnd Bergmann

After trace_selftest_startup_sched_switch is removed, trace_test_buffer() is now only used inside of CONFIG_FUNCTION_TRACER, leading to this warning:

kernel/trace/trace_selftest.c:62:12: error: 'trace_test_buffer' defined but not used [-Werror=unused-function]

The same is true for a few other functions called by trace_test_buffer(), so let's extend the #ifdef to cover all of them together.

Quoted 7 lines
Quoted 2 lines
Fixes d8c4deee6dc6 ("tracing: Remove obsolete sched_switch tracer selftest")

Nevermind, I ran into another problem with this applied: trace_test_buffer() is used elsewhere after all, just not for all possible combinations.

Maybe marking it as __maybe_unused would be more appropriate?

If that quiets the warning for you. This selftest code isn't something for production, so it shouldn't be that critical. It's only used to sanity check various parts of tracing.

-- Steve