From 0b915d6dc50e9e5aeb3e41db9d20dc96d9edee3f Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Sat, 13 Dec 2014 07:50:34 +0000 Subject: datatype: add new subtypes field to account number of concat data types Using the size is confusing since it usually holds the size of the data. Add a new "subtypes" member, which holds the number of datatypes the concat type is made of. Signed-off-by: Patrick McHardy --- src/evaluate.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/evaluate.c') diff --git a/src/evaluate.c b/src/evaluate.c index 07326607..79edf021 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -605,10 +605,10 @@ static int expr_evaluate_concat(struct eval_ctx *ctx, struct expr **expr) { const struct datatype *dtype = ctx->ectx.dtype, *tmp; unsigned int type = dtype ? dtype->type : 0; - int off = dtype ? dtype->size: 0; + int off = dtype ? dtype->subtypes : 0; unsigned int flags = EXPR_F_CONSTANT | EXPR_F_SINGLETON; struct expr *i, *next; - unsigned int n; + unsigned int n, len = 0; n = 1; list_for_each_entry_safe(i, next, &(*expr)->expressions, list) { @@ -624,11 +624,13 @@ static int expr_evaluate_concat(struct eval_ctx *ctx, struct expr **expr) return -1; flags &= i->flags; + len += i->len; n++; } (*expr)->flags |= flags; (*expr)->dtype = concat_type_alloc(*expr); + (*expr)->len = len; if (off > 0) return expr_error(ctx->msgs, *expr, -- cgit v1.2.3