[PATCH v1] libtracefs: Fix sqlhist used uninitialized error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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





[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux