From 26e035f1fc23f92e85f0e347cdd7305d4f16ea7a Mon Sep 17 00:00:00 2001 From: Botond Baranyi Date: Wed, 27 Jul 2016 13:39:38 +0200 Subject: [PATCH] added warning for when the buffer is not empty after decoding in decmatch Change-Id: I3c41a6eb1a8e3b11682b690feecf2f6e68071dc3 Signed-off-by: Botond Baranyi --- compiler2/ttcn3/TtcnTemplate.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/compiler2/ttcn3/TtcnTemplate.cc b/compiler2/ttcn3/TtcnTemplate.cc index d0a29a5..49fcf9d 100644 --- a/compiler2/ttcn3/TtcnTemplate.cc +++ b/compiler2/ttcn3/TtcnTemplate.cc @@ -4539,9 +4539,16 @@ compile_time: "%s val;\n" // decode the value "val.decode(%s_descr_, buff, TTCN_EncDec::CT_%s);\n" - // make sure the buffer is empty after decoding and no errors occurred - "if (TTCN_EncDec::get_last_error_type() != TTCN_EncDec::ET_NONE || " - "buff.get_read_len() != 0) return FALSE;\n" + // make sure no errors occurred (these already displayed warnings during + // decoding) + "if (TTCN_EncDec::get_last_error_type() != TTCN_EncDec::ET_NONE) " + "return FALSE;\n" + // make sure the buffer is empty after decoding, display a warning otherwise + "if (buff.get_read_len() != 0) {\n" + "TTCN_warning(\"Decoded content matching failed, because the buffer was not " + "empty after decoding. Remaining octets: %%d.\", (int)buff.get_read_len());\n" + "return FALSE;\n" + "}\n" // finally, match the decoded value against the target template "return target.match(val%s);\n" "}\n" -- 2.34.1