]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: expr: fix build failure with json support
authorFlorian Westphal <fw@strlen.de>
Tue, 12 Feb 2019 12:21:10 +0000 (13:21 +0100)
committerFlorian Westphal <fw@strlen.de>
Tue, 12 Feb 2019 12:23:41 +0000 (13:23 +0100)
Fixes: e3f195777ee54 ("src: expr: remove expr_ops from struct expr")
Reported-by: Mikhail Morfikov <mmorfikov@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
include/expression.h
src/expression.c
src/json.c

index 18563325012fa63c7b341c2378d464a48415b43f..b681b67f96f44ea22fd99668590988f297386ef9 100644 (file)
@@ -168,6 +168,8 @@ struct expr_ops {
                                               const struct expr *expr);
 };
 
+const struct expr_ops *expr_ops(const struct expr *e);
+
 /**
  * enum expr_flags
  *
index fdbafd19089258430d7c8ddd101f2d6fde42955c..0edc1d22ffce965d079b9d774e29da1a03b681fe 100644 (file)
@@ -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:
index dd7353e400126489477f9dd852247a5f29eb8139..276a3c0f9e7766e5f89e171b179ca750bd8e7b46 100644 (file)
 
 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;