Message ID | 20210804004109.1476661-2-irogers@google.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 3b899a04384a23fe560dd9e4a6a620ab99119076 |
Headers | show |
Series | [1/2] libtracefs: Silence non-literal-null-conversion warning | expand |
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 */
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 */
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 Signed-off-by: Ian Rogers <irogers@google.com> --- src/tracefs-events.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)