On Wed, 2 Feb 2022 13:46:46 -0800 Ian Rogers <irogers@xxxxxxxxxx> wrote: > Caught by clang's -Wsometimes-uninitialized and accepting the suggested > fix: > > lib/trace-cmd/trace-input.c:4325:6: error: variable 'sec' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] > if (handle->file_state >= start_state) { > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > lib/trace-cmd/trace-input.c:4336:6: note: uninitialized use occurs here > if (sec) > ^~~ > lib/trace-cmd/trace-input.c:4325:2: note: remove the 'if' if its condition is always true > if (handle->file_state >= start_state) { > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > lib/trace-cmd/trace-input.c:4311:26: note: initialize the variable 'sec' to silence this warning > struct file_section *sec; > ^ > = NULL -ENOSOB ;-) -- Steve > --- > lib/trace-cmd/trace-input.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c > index ecb5682..57bd4ee 100644 > --- a/lib/trace-cmd/trace-input.c > +++ b/lib/trace-cmd/trace-input.c > @@ -4308,7 +4308,7 @@ int tracecmd_copy_headers(struct tracecmd_input *handle, int fd, > enum tracecmd_file_states start_state, > enum tracecmd_file_states end_state) > { > - struct file_section *sec; > + struct file_section *sec = NULL; > int ret; > > if (!start_state)