This helper function returns a expression value type that represents the
set element key. This functions currently expects two kind of
expressions: set elements and mappings.
Bail out otherwise, if we see anything else, we have to fix our code.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
static struct expr *expr_value(struct expr *expr)
{
- if (expr->ops->type == EXPR_MAPPING)
+ switch (expr->ops->type) {
+ case EXPR_MAPPING:
return expr->left->key;
- else
+ case EXPR_SET_ELEM:
return expr->key;
+ default:
+ BUG("invalid expression type %s\n", expr->ops->name);
+ }
}
static int expr_value_cmp(const void *p1, const void *p2)