Skip to content

Commit aef70eb

Browse files
Tom Rixrostedt
authored andcommitted
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/[email protected] Signed-off-by: Tom Rix <[email protected]> Acked-by: Mark Rutland <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent f94fe70 commit aef70eb

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

samples/ftrace/ftrace-ops.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Arbitrary large value chosen to be sufficiently large to minimize noise but
1313
* sufficiently small to complete quickly.
1414
*/
15-
unsigned int nr_function_calls = 100000;
15+
static unsigned int nr_function_calls = 100000;
1616
module_param(nr_function_calls, uint, 0);
1717
MODULE_PARM_DESC(nr_function_calls, "How many times to call the relevant tracee");
1818

@@ -21,7 +21,7 @@ MODULE_PARM_DESC(nr_function_calls, "How many times to call the relevant tracee"
2121
* be called directly or whether it's necessary to go via the list func, which
2222
* can be significantly more expensive.
2323
*/
24-
unsigned int nr_ops_relevant = 1;
24+
static unsigned int nr_ops_relevant = 1;
2525
module_param(nr_ops_relevant, uint, 0);
2626
MODULE_PARM_DESC(nr_ops_relevant, "How many ftrace_ops to associate with the relevant tracee");
2727

@@ -30,23 +30,23 @@ MODULE_PARM_DESC(nr_ops_relevant, "How many ftrace_ops to associate with the rel
3030
* tracers enabled for distinct functions can force the use of the list func
3131
* and incur overhead for all call sites.
3232
*/
33-
unsigned int nr_ops_irrelevant = 0;
33+
static unsigned int nr_ops_irrelevant;
3434
module_param(nr_ops_irrelevant, uint, 0);
3535
MODULE_PARM_DESC(nr_ops_irrelevant, "How many ftrace_ops to associate with the irrelevant tracee");
3636

3737
/*
3838
* On architectures with DYNAMIC_FTRACE_WITH_REGS, saving the full pt_regs can
3939
* be more expensive than only saving the minimal necessary regs.
4040
*/
41-
bool save_regs = false;
41+
static bool save_regs;
4242
module_param(save_regs, bool, 0);
4343
MODULE_PARM_DESC(save_regs, "Register ops with FTRACE_OPS_FL_SAVE_REGS (save all registers in the trampoline)");
4444

45-
bool assist_recursion = false;
45+
static bool assist_recursion;
4646
module_param(assist_recursion, bool, 0);
4747
MODULE_PARM_DESC(assist_reursion, "Register ops with FTRACE_OPS_FL_RECURSION");
4848

49-
bool assist_rcu = false;
49+
static bool assist_rcu;
5050
module_param(assist_rcu, bool, 0);
5151
MODULE_PARM_DESC(assist_reursion, "Register ops with FTRACE_OPS_FL_RCU");
5252

@@ -55,7 +55,7 @@ MODULE_PARM_DESC(assist_reursion, "Register ops with FTRACE_OPS_FL_RCU");
5555
* overhead. Sometimes a consistency check using a more expensive tracer is
5656
* desireable.
5757
*/
58-
bool check_count = false;
58+
static bool check_count;
5959
module_param(check_count, bool, 0);
6060
MODULE_PARM_DESC(check_count, "Check that tracers are called the expected number of times\n");
6161

@@ -64,7 +64,7 @@ MODULE_PARM_DESC(check_count, "Check that tracers are called the expected number
6464
* runs, but sometimes it can be useful to leave them registered so that they
6565
* can be inspected through the tracefs 'enabled_functions' file.
6666
*/
67-
bool persist = false;
67+
static bool persist;
6868
module_param(persist, bool, 0);
6969
MODULE_PARM_DESC(persist, "Successfully load module and leave ftrace ops registered after test completes\n");
7070

@@ -114,8 +114,8 @@ static void ops_func_count(unsigned long ip, unsigned long parent_ip,
114114
self->count++;
115115
}
116116

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;
119119

120120
static struct sample_ops *ops_alloc_init(void *tracee, ftrace_func_t func,
121121
unsigned long flags, int nr)
@@ -163,8 +163,8 @@ static void ops_check(struct sample_ops *ops, int nr,
163163
}
164164
}
165165

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;
168168

169169
static int __init ftrace_ops_sample_init(void)
170170
{

0 commit comments

Comments
 (0)