ftrace: Fix build warning
PATCH 1/1 ftrace: Fix build warning
If CONFIG_SYSCTL and CONFIG_DYNAMIC_FTRACE is n, build warns:
kernel/trace/ftrace.c:7912:13: error: ‘is_permanent_ops_registered’ defined but not used [-Werror=unused-function]
static bool is_permanent_ops_registered(void)
^~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/trace/ftrace.c:89:12: error: ‘last_ftrace_enabled’ defined but not used [-Werror=unused-variable]
static int last_ftrace_enabled;
^~~~~~~~~~~~~~~~~~~Move is_permanent_ops_registered() to ifdef block and mark last_ftrace_enabled as __maybe_unused to fix this.
--- kernel/trace/ftrace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/ftrace.c +2 -2
@@ -86,7 +86,7 @@ struct ftrace_ops ftrace_list_end __read_mostly = {/* ftrace_enabled is a method to turn ftrace on or off */ int ftrace_enabled__read_mostly ; -static int last_ftrace_enabled; +static int __maybe_unused last_ftrace_enabled;/* Current function tracing op */ struct ftrace_ops *function_trace_op__read_mostly = &ftrace_list_end;
@@ -7909,6 +7909,7 @@ int unregister_ftrace_function(struct ftrace_ops *ops) }EXPORT_SYMBOL_GPL (unregister_ftrace_function); +#ifdef CONFIG_SYSCTL static bool is_permanent_ops_registered (void ) {struct ftrace_ops *op;
@@ -7921,7 +7922,6 @@ static bool is_permanent_ops_registered(void)return false; } -#ifdef CONFIG_SYSCTL static int ftrace_enable_sysctl (struct ctl_table *table,int write,void *buffer,size_t *lenp,loff_t *ppos)
Signature · 1 line
2.17.1
Quoted 9 lines · On Thu, 7 Apr 2022 15:46:12 +0800 YueHaibing <[email protected]> wrote:
If
CONFIG_SYSCTLandCONFIG_DYNAMIC_FTRACEis n, build warns:
kernel/trace/ftrace.c:7912:13: error: ‘is_permanent_ops_registered’ defined but not used [-Werror=unused-function]
static boolis_permanent_ops_registered(void)^~~~~~~~~~~~~~~~~~~~~~~~~~~ kernel/trace/ftrace.c:89:12: error: ‘last_ftrace_enabled’ defined but not used [-Werror=unused-variable] static int last_ftrace_enabled; ^~~~~~~~~~~~~~~~~~~
Quoted 8 lines
Move
is_permanent_ops_registered()to ifdef block and marklast_ftrace_enabledas__maybe_unusedto fix this.Fixes 7cde53da38a3 ("ftrace: move sysctl_ftrace_enabled to ftrace.c")Signed-off-by YueHaibing <[email protected]>--- kernel/trace/ftrace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
-- Steve
Quoted 15 lines · Steven Rostedt
Quoted 12 lines · On Thu, 7 Apr 2022 15:46:12 +0800 YueHaibing <[email protected]> wrote:
If
CONFIG_SYSCTLandCONFIG_DYNAMIC_FTRACEis n, build warns:
kernel/trace/ftrace.c:7912:13: error: ‘is_permanent_ops_registered’ defined but not used [-Werror=unused-function]
static boolis_permanent_ops_registered(void)^~~~~~~~~~~~~~~~~~~~~~~~~~~ kernel/trace/ftrace.c:89:12: error: ‘last_ftrace_enabled’ defined but not used [-Werror=unused-variable] static int last_ftrace_enabled; ^~~~~~~~~~~~~~~~~~~Move
is_permanent_ops_registered()to ifdef block and marklast_ftrace_enabledas__maybe_unusedto fix this.
Quoted 7 lines
Quoted 5 lines
Fixes 7cde53da38a3 ("ftrace: move sysctl_ftrace_enabled to ftrace.c")Signed-off-by YueHaibing <[email protected]>--- kernel/trace/ftrace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Queued onto sysctl-testing. I have one more fix I just posted for this too.
Luis