[Spice-commits] 2 commits - python_modules/demarshal.py spice.proto tests/test-marshallers.h tests/test-marshallers.proto
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu May 17 20:06:59 UTC 2018
python_modules/demarshal.py | 3 +--
spice.proto | 6 +++---
tests/test-marshallers.h | 4 ++++
tests/test-marshallers.proto | 4 ++++
4 files changed, 12 insertions(+), 5 deletions(-)
New commits:
commit d84f5a5e6387510779afc1c5df3883f988174310
Author: Eduardo Lima (Etrunko) <etrunko at redhat.com>
Date: Thu May 17 11:38:03 2018 -0300
Fix field names for Smartcard protocol structures
Rename struct VSCMsgReaderAdd field 'reader_name' to 'name', and struct
VSCMsgATR field 'data' to 'atr' to match their definitions in file
vscard_common.h.
The error log follows:
generated_server_demarshallers.c:1985:30: note: each undeclared identifier is reported only once for each function it appears in
generated_server_demarshallers.c:1994:15: error: ‘VSCMsgReaderAdd {aka struct VSCMsgReaderAdd}’ has no member named ‘reader_name’
memcpy(out->reader_name, in, reader_name__nelements);
^~
Signed-off-by: Eduardo Lima (Etrunko) <etrunko at redhat.com>
Acked-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/spice.proto b/spice.proto
index 69f169e..6ee4766 100644
--- a/spice.proto
+++ b/spice.proto
@@ -1383,11 +1383,11 @@ struct VscMessageAPDU {
} @ctype(VSCMsgAPDU);
struct VscMessageATR {
- uint8 data[];
+ uint8 atr[];
} @ctype(VSCMsgATR);
struct VscMessageReaderAdd {
- int8 *reader_name[] @zero_terminated @nonnull @end @nomarshal;
+ int8 *name[] @zero_terminated @nonnull @end @nomarshal;
} @ctype(VSCMsgReaderAdd);
channel SmartcardChannel : BaseChannel {
@@ -1435,7 +1435,7 @@ channel SmartcardChannel : BaseChannel {
} @ctype(VSCMsgATR) atr = 101;
message {
- int8 reader_name[] @zero_terminated @nonnull;
+ int8 name[] @zero_terminated @nonnull;
} @ctype(VSCMsgReaderAdd) reader_add = 101;
*/
} @ifdef(USE_SMARTCARD);
commit 20bda4dba9a7cdb534de1cda3ccb9ffcee5d76a1
Author: Eduardo Lima (Etrunko) <etrunko at redhat.com>
Date: Thu May 17 14:41:10 2018 -0300
Fix demarshaller code generator
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 at redhat.com>
Acked-by: Frediano Ziglio <fziglio at redhat.com>
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 {
More information about the Spice-commits
mailing list