ftrace: avoid unused-variable warning
PATCH 1/1 ftrace: avoid unused-variable warning
When CONFIG_DYNAMIC_FTRACE is disabled, we get a harmless compile-time warning:
kernel/trace/trace_stack.c: In function 'stack_trace_filter_open':kernel/trace/trace_stack.c:412:21: error: unused variable 'ops' [-Werror=unused-variable]
We could replace the macros in linux/ftrace.h with inline functions, which would solve this problem for all callers. However, as these are only called internally in the ftrace code, it seems simpler to change the caller instead.
--- kernel/trace/trace_stack.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
kernel/trace/trace_stack.c +1 -3
@@ -409,9 +409,7 @@ static const struct file_operations stack_trace_fops = {static int stack_trace_filter_open (struct inode *inode,struct file *file) { -struct ftrace_ops *ops = inode->i_private; - -return ftrace_regex_open (ops,FTRACE_ITER_FILTER , +return ftrace_regex_open (inode->i_private,FTRACE_ITER_FILTER , inode, file); }
Signature · 1 line
2.9.0
Steven Rostedt
maintainerQuoted 10 lines · On Mon, 10 Jul 2017 13:04:56 +0200 Arnd Bergmann <[email protected]> wrote:
When
CONFIG_DYNAMIC_FTRACEis disabled, we get a harmless compile-time warning:
kernel/trace/trace_stack.c: In function 'stack_trace_filter_open':kernel/trace/trace_stack.c:412:21: error: unused variable 'ops' [-Werror=unused-variable]We could replace the macros in
linux/ftrace.hwith inline functions, which would solve this problem for all callers. However, as these are only called internally in the ftrace code, it seems simpler to change the caller instead.
Actually we can't replace them, as they are called when ftrace is not defined, and the ops isn't defined either (which the comment above the macros state).
Quoted 12 lines
Fixes 0f17976568b3 ("ftrace: Fix regression with module command in stack_trace_filter")Signed-off-by Arnd Bergmann <[email protected]>--- kernel/trace/trace_stack.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)kernel/trace/trace_stack.c +0
-0
kernel/trace/trace_stack.c static const struct file_operations stack_trace_fops = { · line 412
Quoted 7 lines
kernel/trace/trace_stack.c +1
-3@@ -409,9 +409,7 @@ static const struct file_operations stack_trace_fops = {static int stack_trace_filter_open (struct inode *inode,struct file *file) { -struct ftrace_ops *ops = inode->i_private; - - return ftrace_regex_open(ops, FTRACE_ITER_FILTER, + return ftrace_regex_open(inode->i_private, FTRACE_ITER_FILTER,
Actually, I'm glad you mentioned this warning. Because this file should not be exposed if DYNAMIC_FTRACE is not set.
I'll fix.
Thanks!
-- Steve
Quoted 3 lines
kernel/trace/trace_stack.c +0
-0inode, file); }