Message ID | 20210907203137.3954523-1-irogers@google.com (mailing list archive) |
---|---|
State | Accepted |
Commit | ee40c7468c0a14d6db7227dc1640a63158861415 |
Headers | show |
Series | [v2] libtracefs: Fix sometimes uninitialized warning. | expand |
diff --git a/src/tracefs-sqlhist.c b/src/tracefs-sqlhist.c index 88e9675..d77ce86 100644 --- a/src/tracefs-sqlhist.c +++ b/src/tracefs-sqlhist.c @@ -1097,7 +1097,8 @@ static int build_filter(struct tep_handle *tep, struct sqlhist_bison *sb, case FILTER_BIN_AND: cmp = TRACEFS_COMPARE_AND; break; case FILTER_STR_CMP: cmp = TRACEFS_COMPARE_RE; break; default: - break; + fprintf(stderr, "Error invalid filter type '%d'", filter->type); + return ERANGE; } ret = append_filter(synth, TRACEFS_FILTER_COMPARE,
The warning with clang looks like: src/tracefs-sqlhist.c:1107:2: error: variable 'cmp' is used uninitialized whenever switch default is taken [-Werror,-Wsometimes-uninitialized] default: ^~~~~~~ third_party/libtracefs/src/tracefs-sqlhist.c:1112:35: note: uninitialized use occurs here filter->lval->field.field, cmp, val); ^~~ third_party/libtracefs/src/tracefs-sqlhist.c:1033:2: note: variable 'cmp' is declared here enum tracefs_compare cmp; Signed-off-by: Ian Rogers <irogers@google.com> --- src/tracefs-sqlhist.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)