Message ID | 20220202214646.553872-1-irogers@google.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 5a0d565f55bca4299716eaeb8cb3b042be1f1c9a |
Headers | show |
Series | trace-cmd: Fix use of uninitialized variable | expand |
On Wed, 2 Feb 2022 13:46:46 -0800 Ian Rogers <irogers@google.com> 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)
On Tue, 15 Feb 2022 12:09:48 -0500 Steven Rostedt <rostedt@goodmis.org> wrote: > -ENOSOB > > ;-) So I applied this patch myself and gave a Reported-by to you, as it requires the author to have their SOB. -- Steve
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)