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>
This commit is contained in:
committed by
Arnaldo Carvalho de Melo
parent
3d05181a08
commit
29396cd573
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user