* [PATCH v1] libtracefs: Fix sqlhist used uninitialized error
@ 2024-01-02 17:48 Ian Rogers
0 siblings, 0 replies; only message in thread
From: Ian Rogers @ 2024-01-02 17:48 UTC (permalink / raw)
To: linux-trace-devel, Steven Rostedt; +Cc: Ian Rogers
Fix the following used uninitialized error detected by clang:
```
src/tracefs-sqlhist.c:657:13: error: variable 'extra_label' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
657 | } else if (expr == table->from) {
| ^~~~~~~~~~~~~~~~~~~
src/tracefs-sqlhist.c:662:6: note: uninitialized use occurs here
662 | if (extra_label)
| ^~~~~~~~~~~
src/tracefs-sqlhist.c:657:9: note: remove the 'if' if its condition is always true
657 | } else if (expr == table->from) {
| ^~~~~~~~~~~~~~~~~~~~~~~~
src/tracefs-sqlhist.c:645:25: note: initialize the variable 'extra_label' to silence this warning
645 | const char *extra_label;
| ^
| = NULL
1 error generated.
```
Signed-off-by: Ian Rogers <irogers@google.com>
---
src/tracefs-sqlhist.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/tracefs-sqlhist.c b/src/tracefs-sqlhist.c
index 3592000..e7a4158 100644
--- a/src/tracefs-sqlhist.c
+++ b/src/tracefs-sqlhist.c
@@ -642,7 +642,7 @@ static int update_vars(struct tep_handle *tep,
enum field_type ftype = FIELD_NONE;
struct tep_event *event;
struct field *field;
- const char *extra_label;
+ const char *extra_label = NULL;
const char *label;
const char *raw = event_field->raw;
const char *event_name;
--
2.43.0.472.g3155946c3a-goog
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-02 17:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-02 17:48 [PATCH v1] libtracefs: Fix sqlhist used uninitialized error Ian Rogers
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).