Even though commit df4ec5c3186e796624e4bbf2dc4a269faf2823f6 commented out most of smartcard code which triggered this error, it still might happen if a new message is added with an array member. The reason is a missing declaration of mem_size, which is fixed simply by checking if the attribute 'nocopy' is present. The error log follows: generated_server_demarshallers.c: In function ‘parse_msgc_smartcard_reader_add’: generated_server_demarshallers.c:1985:30: error: ‘mem_size’ undeclared (first use in this function); did you mean ‘nw_size’? data = (uint8_t *)malloc(mem_size); ^~~~~~~~ nw_size This patch also updates test-marshallers so that this bug is triggered. The diff between generated demarshallers with the patch applied follows: --- tests/generated_test_demarshallers.c.old 2018-05-17 14:35:29.234056487 -0300 +++ tests/generated_test_demarshallers.c 2018-05-17 14:35:40.554031295 -0300 @@ -286,6 +286,7 @@ static uint8_t * parse_msg_main_ArrayMes uint8_t *start = message_start; uint8_t *data = NULL; uint64_t nw_size; + uint64_t mem_size; uint8_t *in, *end; uint64_t name__nw_size; uint64_t name__nelements; @@ -298,6 +299,7 @@ static uint8_t * parse_msg_main_ArrayMes } nw_size = 0 + name__nw_size; + mem_size = sizeof(SpiceMsgMainArrayMessage); /* Check if message fits in reported side */ if (nw_size > (uintptr_t) (message_end - start)) { Signed-off-by: Eduardo Lima (Etrunko) <etrunko@xxxxxxxxxx> --- python_modules/demarshal.py | 3 +-- tests/test-marshallers.h | 4 ++++ tests/test-marshallers.proto | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/python_modules/demarshal.py b/python_modules/demarshal.py index 8d3f5cb..7b53361 100644 --- a/python_modules/demarshal.py +++ b/python_modules/demarshal.py @@ -1039,8 +1039,7 @@ def write_msg_parser(writer, message): msg_type = message.c_type() msg_sizeof = message.sizeof() - want_mem_size = (len(message.members) != 1 or message.members[0].is_fixed_nw_size() - or not message.members[0].is_array()) + want_mem_size = not message.has_attr("nocopy") writer.newline() if message.has_attr("ifdef"): diff --git a/tests/test-marshallers.h b/tests/test-marshallers.h index 7e5a0b2..7b9f6c5 100644 --- a/tests/test-marshallers.h +++ b/tests/test-marshallers.h @@ -8,5 +8,9 @@ typedef struct { uint64_t *data; } SpiceMsgMainShortDataSubMarshall; +typedef struct { + int8_t *name; +} SpiceMsgMainArrayMessage; + #endif /* _H_TEST_MARSHALLERS */ diff --git a/tests/test-marshallers.proto b/tests/test-marshallers.proto index 68b5822..95d086c 100644 --- a/tests/test-marshallers.proto +++ b/tests/test-marshallers.proto @@ -4,6 +4,10 @@ channel TestChannel { uint32 data_size; uint64 *data[data_size] @marshall; } ShortDataSubMarshall; + + message { + int8 name[]; + } ArrayMessage; }; protocol Spice { -- 2.14.3 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel