Split it into its own function, caller is already quite big. Signed-off-by: Florian Westphal <fw@xxxxxxxxx> --- src/evaluate.c | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/evaluate.c b/src/evaluate.c index ed78896..4d741e3 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -1119,6 +1119,26 @@ static int binop_transfer(struct eval_ctx *ctx, struct expr **expr) return 0; } +static enum ops expr_defaultop(const struct expr *e) +{ + switch (e->ops->type) { + case EXPR_RANGE: + return OP_RANGE; + case EXPR_SET: + case EXPR_SET_REF: + return OP_LOOKUP; + case EXPR_LIST: + return OP_FLAGCMP; + default: + if (e->dtype->basetype != NULL && + e->dtype->basetype->type == TYPE_BITMASK) + return OP_FLAGCMP; + break; + } + + return OP_EQ; +} + static int expr_evaluate_relational(struct eval_ctx *ctx, struct expr **expr) { struct expr *rel = *expr, *left, *right; @@ -1131,27 +1151,8 @@ static int expr_evaluate_relational(struct eval_ctx *ctx, struct expr **expr) return -1; right = rel->right; - if (rel->op == OP_IMPLICIT) { - switch (right->ops->type) { - case EXPR_RANGE: - rel->op = OP_RANGE; - break; - case EXPR_SET: - case EXPR_SET_REF: - rel->op = OP_LOOKUP; - break; - case EXPR_LIST: - rel->op = OP_FLAGCMP; - break; - default: - if (right->dtype->basetype != NULL && - right->dtype->basetype->type == TYPE_BITMASK) - rel->op = OP_FLAGCMP; - else - rel->op = OP_EQ; - break; - } - } + if (rel->op == OP_IMPLICIT) + rel->op = expr_defaultop(rel->right); if (!expr_is_constant(right)) return expr_binary_error(ctx->msgs, right, rel, -- 2.4.10 -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html