diff mbox series

[v1] libtracefs: Fix sqlhist used uninitialized error

Message ID 20240102174817.1051566-1-irogers@google.com (mailing list archive)
State Accepted
Commit a9dae653c6d257b4026325c1b2d72c6cf7d879ac
Headers show
Series [v1] libtracefs: Fix sqlhist used uninitialized error | expand

Commit Message

Ian Rogers Jan. 2, 2024, 5:48 p.m. UTC
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 mbox series

Patch

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;