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/datatype.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/datatype.c') diff --git a/src/datatype.c b/src/datatype.c index 807b0f18..8583531f 100644 --- a/src/datatype.c +++ b/src/datatype.c @@ -929,10 +929,10 @@ const struct datatype *concat_type_alloc(const struct expr *expr) struct expr *i; char desc[256] = "concatenation of ("; char name[256] = ""; - unsigned int type = 0, size = 0; + unsigned int type = 0, size = 0, subtypes = 0; list_for_each_entry(i, &expr->expressions, list) { - if (size != 0) { + if (subtypes != 0) { strncat(desc, ", ", sizeof(desc) - strlen(desc) - 1); strncat(name, " . ", sizeof(name) - strlen(name) - 1); } @@ -941,13 +941,15 @@ const struct datatype *concat_type_alloc(const struct expr *expr) type <<= 8; type |= i->dtype->type; - size++; + size += i->dtype->size; + subtypes++; } strncat(desc, ")", sizeof(desc) - strlen(desc) - 1); dtype = dtype_alloc(); dtype->type = type; dtype->size = size; + dtype->subtypes = subtypes; dtype->name = xstrdup(name); dtype->desc = xstrdup(desc); dtype->parse = concat_type_parse; -- cgit v1.2.3