diff options
author | Ian Rogers <irogers@google.com> | 2020-08-26 08:30:55 -0700 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2020-11-16 14:09:18 -0300 |
commit | 29396cd573da08ae9ab0b75925c2f6b3cabb9dfa (patch) | |
tree | 49d6b307007eb1a1ecccc2721bfb13607785bb10 /tools/perf/util/expr.h | |
parent | 3d05181a085c7a070746c838ea25aebf25f17d52 (diff) | |
download | lwn-29396cd573da08ae9ab0b75925c2f6b3cabb9dfa.tar.gz lwn-29396cd573da08ae9ab0b75925c2f6b3cabb9dfa.zip |
perf expr: Force encapsulation on expr_id_data
This patch resolves some undefined behavior where variables in
expr_id_data were accessed (for debugging) without being defined. To
better enforce the tagged union behavior, the struct is moved into
expr.c and accessors provided. Tag values (kinds) are explicitly
identified.
Signed-off-by: Ian Rogers <irogers@google.com>
Reviewed-By: Kajol Jain<kjain@linux.ibm.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Link: https://lore.kernel.org/r/20200826153055.2067780-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/expr.h')
-rw-r--r-- | tools/perf/util/expr.h | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/tools/perf/util/expr.h b/tools/perf/util/expr.h index fc2b5e824a66..dcf8d19b83c8 100644 --- a/tools/perf/util/expr.h +++ b/tools/perf/util/expr.h @@ -23,19 +23,7 @@ struct expr_parse_ctx { struct expr_id *parent; }; -struct expr_id_data { - union { - double val; - struct { - const char *metric_name; - const char *metric_expr; - bool counted; - } ref; - struct expr_id *parent; - }; - - bool is_ref; -}; +struct expr_id_data; struct expr_scanner_ctx { int start_token; @@ -57,4 +45,7 @@ int expr__parse(double *final_val, struct expr_parse_ctx *ctx, int expr__find_other(const char *expr, const char *one, struct expr_parse_ctx *ids, int runtime); +double expr_id_data__value(const struct expr_id_data *data); +struct expr_id *expr_id_data__parent(struct expr_id_data *data); + #endif |