summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/expression.h2
-rw-r--r--src/expression.c4
-rw-r--r--src/json.c8
3 files changed, 8 insertions, 6 deletions
diff --git a/include/expression.h b/include/expression.h
index 18563325..b681b67f 100644
--- a/include/expression.h
+++ b/include/expression.h
@@ -168,6 +168,8 @@ struct expr_ops {
const struct expr *expr);
};
+const struct expr_ops *expr_ops(const struct expr *e);
+
/**
* enum expr_flags
*
diff --git a/src/expression.c b/src/expression.c
index fdbafd19..0edc1d22 100644
--- a/src/expression.c
+++ b/src/expression.c
@@ -36,8 +36,6 @@ extern const struct expr_ops rt_expr_ops;
extern const struct expr_ops socket_expr_ops;
extern const struct expr_ops xfrm_expr_ops;
-static const struct expr_ops *expr_ops(const struct expr *e);
-
struct expr *expr_alloc(const struct location *loc, enum expr_types etype,
const struct datatype *dtype, enum byteorder byteorder,
unsigned int len)
@@ -1171,7 +1169,7 @@ void range_expr_value_high(mpz_t rop, const struct expr *expr)
}
}
-static const struct expr_ops *expr_ops(const struct expr *e)
+const struct expr_ops *expr_ops(const struct expr *e)
{
switch (e->etype) {
case EXPR_INVALID:
diff --git a/src/json.c b/src/json.c
index dd7353e4..276a3c0f 100644
--- a/src/json.c
+++ b/src/json.c
@@ -33,18 +33,20 @@
static json_t *expr_print_json(const struct expr *expr, struct output_ctx *octx)
{
+ const struct expr_ops *ops;
char buf[1024];
FILE *fp;
- if (expr->ops->json)
- return expr->ops->json(expr, octx);
+ ops = expr_ops(expr);
+ if (ops->json)
+ return ops->json(expr, octx);
printf("warning: expr ops %s have no json callback\n", expr_name(expr));
fp = octx->output_fp;
octx->output_fp = fmemopen(buf, 1024, "w");
- expr->ops->print(expr, octx);
+ ops->print(expr, octx);
fclose(octx->output_fp);
octx->output_fp = fp;