All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Ian Rogers <irogers@google.com>
Cc: linux-trace-devel@vger.kernel.org,
	Tzvetomir Stoyanov <tz.stoyanov@gmail.com>,
	Claire Jensen <cjense@google.com>
Subject: Re: [PATCH 2/2] libtracefs: Silence sometimes-uninitialized warning
Date: Tue, 3 Aug 2021 20:51:14 -0400	[thread overview]
Message-ID: <20210803205114.24edfe8c@rorschach.local.home> (raw)
In-Reply-To: <20210804004109.1476661-2-irogers@google.com>

On Tue,  3 Aug 2021 17:41:09 -0700
Ian Rogers <irogers@google.com> wrote:

> Warning generated by clang:
> 
> src/tracefs-events.c:1046:6: error: variable 'ret' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
>         if (!systems)
>             ^~~~~~~~
> src/tracefs-events.c:1101:9: note: uninitialized use occurs here
>         return ret;
>                ^~~
> src/tracefs-events.c:1046:2: note: remove the 'if' if its condition is always false
>         if (!systems)
>         ^~~~~~~~~~~~~
> src/tracefs-events.c:1038:9: note: initialize the variable 'ret' to silence this warning
>         int ret;
>                ^
>                 = 0

That's a legitimate path to have ret returned without being initialized.

I'll add both patches to my next push.

Thanks!

-- Steve


> 
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
>  src/tracefs-events.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/tracefs-events.c b/src/tracefs-events.c
> index 8d84838..4679926 100644
> --- a/src/tracefs-events.c
> +++ b/src/tracefs-events.c
> @@ -1035,7 +1035,7 @@ static int event_enable_disable(struct tracefs_instance *instance,
>  	regex_t system_re, event_re;
>  	char **systems;
>  	char **events = NULL;
> -	int ret;
> +	int ret = -1;
>  	int s, e;
>  
>  	/* Handle all events first */


  reply	other threads:[~2021-08-04  0:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-04  0:41 [PATCH 1/2] libtracefs: Silence non-literal-null-conversion warning Ian Rogers
2021-08-04  0:41 ` [PATCH 2/2] libtracefs: Silence sometimes-uninitialized warning Ian Rogers
2021-08-04  0:51   ` Steven Rostedt [this message]
2021-08-04  0:50 ` [PATCH 1/2] libtracefs: Silence non-literal-null-conversion warning Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210803205114.24edfe8c@rorschach.local.home \
    --to=rostedt@goodmis.org \
    --cc=cjense@google.com \
    --cc=irogers@google.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=tz.stoyanov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.