Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

samples: ftrace: Make some global variables static

smatch reports this representative issue
samples/ftrace/ftrace-ops.c:15:14: warning: symbol 'nr_function_calls' was not declared. Should it be static?

The nr_functions_calls and several other global variables are only
used in ftrace-ops.c, so they should be static.
Remove the instances of initializing static int to 0.

Link: https://lore.kernel.org/linux-trace-kernel/20230130193708.1378108-1-trix@redhat.com

Signed-off-by: Tom Rix <trix@redhat.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

authored by

Tom Rix and committed by
Steven Rostedt (Google)
aef70ebd f94fe704

+12 -12
+12 -12
samples/ftrace/ftrace-ops.c
··· 12 12 * Arbitrary large value chosen to be sufficiently large to minimize noise but 13 13 * sufficiently small to complete quickly. 14 14 */ 15 - unsigned int nr_function_calls = 100000; 15 + static unsigned int nr_function_calls = 100000; 16 16 module_param(nr_function_calls, uint, 0); 17 17 MODULE_PARM_DESC(nr_function_calls, "How many times to call the relevant tracee"); 18 18 ··· 21 21 * be called directly or whether it's necessary to go via the list func, which 22 22 * can be significantly more expensive. 23 23 */ 24 - unsigned int nr_ops_relevant = 1; 24 + static unsigned int nr_ops_relevant = 1; 25 25 module_param(nr_ops_relevant, uint, 0); 26 26 MODULE_PARM_DESC(nr_ops_relevant, "How many ftrace_ops to associate with the relevant tracee"); 27 27 ··· 30 30 * tracers enabled for distinct functions can force the use of the list func 31 31 * and incur overhead for all call sites. 32 32 */ 33 - unsigned int nr_ops_irrelevant = 0; 33 + static unsigned int nr_ops_irrelevant; 34 34 module_param(nr_ops_irrelevant, uint, 0); 35 35 MODULE_PARM_DESC(nr_ops_irrelevant, "How many ftrace_ops to associate with the irrelevant tracee"); 36 36 ··· 38 38 * On architectures with DYNAMIC_FTRACE_WITH_REGS, saving the full pt_regs can 39 39 * be more expensive than only saving the minimal necessary regs. 40 40 */ 41 - bool save_regs = false; 41 + static bool save_regs; 42 42 module_param(save_regs, bool, 0); 43 43 MODULE_PARM_DESC(save_regs, "Register ops with FTRACE_OPS_FL_SAVE_REGS (save all registers in the trampoline)"); 44 44 45 - bool assist_recursion = false; 45 + static bool assist_recursion; 46 46 module_param(assist_recursion, bool, 0); 47 47 MODULE_PARM_DESC(assist_reursion, "Register ops with FTRACE_OPS_FL_RECURSION"); 48 48 49 - bool assist_rcu = false; 49 + static bool assist_rcu; 50 50 module_param(assist_rcu, bool, 0); 51 51 MODULE_PARM_DESC(assist_reursion, "Register ops with FTRACE_OPS_FL_RCU"); 52 52 ··· 55 55 * overhead. Sometimes a consistency check using a more expensive tracer is 56 56 * desireable. 57 57 */ 58 - bool check_count = false; 58 + static bool check_count; 59 59 module_param(check_count, bool, 0); 60 60 MODULE_PARM_DESC(check_count, "Check that tracers are called the expected number of times\n"); 61 61 ··· 64 64 * runs, but sometimes it can be useful to leave them registered so that they 65 65 * can be inspected through the tracefs 'enabled_functions' file. 66 66 */ 67 - bool persist = false; 67 + static bool persist; 68 68 module_param(persist, bool, 0); 69 69 MODULE_PARM_DESC(persist, "Successfully load module and leave ftrace ops registered after test completes\n"); 70 70 ··· 114 114 self->count++; 115 115 } 116 116 117 - struct sample_ops *ops_relevant; 118 - struct sample_ops *ops_irrelevant; 117 + static struct sample_ops *ops_relevant; 118 + static struct sample_ops *ops_irrelevant; 119 119 120 120 static struct sample_ops *ops_alloc_init(void *tracee, ftrace_func_t func, 121 121 unsigned long flags, int nr) ··· 163 163 } 164 164 } 165 165 166 - ftrace_func_t tracer_relevant = ops_func_nop; 167 - ftrace_func_t tracer_irrelevant = ops_func_nop; 166 + static ftrace_func_t tracer_relevant = ops_func_nop; 167 + static ftrace_func_t tracer_irrelevant = ops_func_nop; 168 168 169 169 static int __init ftrace_ops_sample_init(void) 170 170 {