]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
evaluate: determine implicit relational op before RHS constant checks
authorPatrick McHardy <kaber@trash.net>
Tue, 4 Feb 2014 08:09:27 +0000 (08:09 +0000)
committerPatrick McHardy <kaber@trash.net>
Tue, 4 Feb 2014 08:09:27 +0000 (08:09 +0000)
The symbol for the relational op is shown in the error message. Since
OP_IMPLICIT doesn't have a symbol, (null) is shown. Fix by determining
the implicit op before checking for constants.

Error: Right hand side of relational expression ((null)) must be constant
=>
Error: Right hand side of relational expression (==) must be constant

Signed-off-by: Patrick McHardy <kaber@trash.net>
src/evaluate.c

index 215a004af3354f00436a3688923d4773e8f3e42d..a01d2a53b80077d3b986c8069c387d3f9edebc47 100644 (file)
@@ -872,17 +872,6 @@ static int expr_evaluate_relational(struct eval_ctx *ctx, struct expr **expr)
                return -1;
        right = rel->right;
 
-       if (!expr_is_constant(right))
-               return expr_binary_error(ctx, right, rel,
-                                        "Right hand side of relational "
-                                        "expression (%s) must be constant",
-                                        expr_op_symbols[rel->op]);
-       if (expr_is_constant(left))
-               return expr_binary_error(ctx, left, right,
-                                        "Relational expression (%s) has "
-                                        "constant value",
-                                        expr_op_symbols[rel->op]);
-
        if (rel->op == OP_IMPLICIT) {
                switch (right->ops->type) {
                case EXPR_RANGE:
@@ -901,6 +890,17 @@ static int expr_evaluate_relational(struct eval_ctx *ctx, struct expr **expr)
                }
        }
 
+       if (!expr_is_constant(right))
+               return expr_binary_error(ctx, right, rel,
+                                        "Right hand side of relational "
+                                        "expression (%s) must be constant",
+                                        expr_op_symbols[rel->op]);
+       if (expr_is_constant(left))
+               return expr_binary_error(ctx, left, right,
+                                        "Relational expression (%s) has "
+                                        "constant value",
+                                        expr_op_symbols[rel->op]);
+
        switch (rel->op) {
        case OP_LOOKUP:
                /* A literal set expression implicitly declares the set */