Re: [PATCH] samples: ftrace: make some global variables static

From: Steven Rostedt
Date: Tue Jan 31 2023 - 10:40:48 EST


On Tue, 31 Jan 2023 10:09:25 +0000
Mark Rutland <mark.rutland@xxxxxxx> wrote:

> On Mon, Jan 30, 2023 at 11:37:08AM -0800, Tom Rix wrote:
> > 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.
>
> This makes sense to me.
>
> > Remove the instances of initializing static int to 0.
>
> I appreciate that static variables get implicitly zero initialized, but
> dropping the initialization is inconsistent with the other control variables,
> and IMO it's quite confusing, so I'd prefer to keep that for clarity. I note
> you've also dropped the initialization of a bool to false, whereas the above
> just mentions int.
>
> I'd prefer to keep the initialization, but I'll defre to Steve if he thinks
> differently. :)

Yeah, I'm fine with dropping the initialization of even bool (I don't
initialize bool to false either). Everything in the BSS section is always
initialized to zero, and in C, false is the same as zero.

>
> > Signed-off-by: Tom Rix <trix@xxxxxxxxxx>
>
> With the above taken into account:
>
> Acked-by: Mark Rutland <mark.rutland@xxxxxxx>

Thanks,

-- Steve