* [PATCH] trace-cmd: Fix use of uninitialized variable
@ 2022-02-02 21:46 Ian Rogers
2022-02-15 17:09 ` Steven Rostedt
0 siblings, 1 reply; 3+ messages in thread
From: Ian Rogers @ 2022-02-02 21:46 UTC (permalink / raw)
To: linux-trace-devel, Tzvetomir Stoyanov, Steven Rostedt; +Cc: Ian Rogers
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
---
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)
--
2.35.0.rc2.247.g8bbb082509-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] trace-cmd: Fix use of uninitialized variable
2022-02-02 21:46 [PATCH] trace-cmd: Fix use of uninitialized variable Ian Rogers
@ 2022-02-15 17:09 ` Steven Rostedt
2022-02-24 19:39 ` Steven Rostedt
0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2022-02-15 17:09 UTC (permalink / raw)
To: Ian Rogers; +Cc: linux-trace-devel, Tzvetomir Stoyanov
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)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] trace-cmd: Fix use of uninitialized variable
2022-02-15 17:09 ` Steven Rostedt
@ 2022-02-24 19:39 ` Steven Rostedt
0 siblings, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2022-02-24 19:39 UTC (permalink / raw)
To: Ian Rogers; +Cc: linux-trace-devel, Tzvetomir Stoyanov
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-02-24 19:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-02 21:46 [PATCH] trace-cmd: Fix use of uninitialized variable Ian Rogers
2022-02-15 17:09 ` Steven Rostedt
2022-02-24 19:39 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).