Commit 8478ba91 authored by Kristof Szabados's avatar Kristof Szabados
Browse files

the get_next_token function should return size_t (unsigned value) ... and this...


the get_next_token function should return size_t (unsigned value) ... and this also revealed some incorrect error handling in some parts of the code.
Signed-off-by: Kristof Szabados's avatarKristof Szabados <Kristof.Szabados@ericsson.com>
parent 8cdabe89
...@@ -202,7 +202,7 @@ bool JSON_Tokenizer::check_for_literal(const char* p_literal) ...@@ -202,7 +202,7 @@ bool JSON_Tokenizer::check_for_literal(const char* p_literal)
return false; return false;
} }
int JSON_Tokenizer::get_next_token(json_token_t* p_token, char** p_token_str, size_t* p_str_len) size_t JSON_Tokenizer::get_next_token(json_token_t* p_token, char** p_token_str, size_t* p_str_len)
{ {
size_t start_pos = buf_pos; size_t start_pos = buf_pos;
*p_token = JSON_TOKEN_NONE; *p_token = JSON_TOKEN_NONE;
......
...@@ -145,7 +145,7 @@ public: ...@@ -145,7 +145,7 @@ public:
* @return The number of characters extracted * @return The number of characters extracted
* @note The token data is not copied, *p_token_str will point to the start of the * @note The token data is not copied, *p_token_str will point to the start of the
* data in the tokenizer's buffer. */ * data in the tokenizer's buffer. */
int get_next_token(json_token_t* p_token, char** p_token_str, size_t* p_str_len); size_t get_next_token(json_token_t* p_token, char** p_token_str, size_t* p_str_len);
/** Gets the current read position in the buffer. /** Gets the current read position in the buffer.
* This is where get_next_token() will read from next. */ * This is where get_next_token() will read from next. */
......
...@@ -810,7 +810,7 @@ void defEnumClass(const enum_def *edef, output_struct *output) ...@@ -810,7 +810,7 @@ void defEnumClass(const enum_def *edef, output_struct *output)
" char* value = 0;\n" " char* value = 0;\n"
" size_t value_len = 0;\n" " size_t value_len = 0;\n"
" boolean error = FALSE;\n" " boolean error = FALSE;\n"
" int dec_len = 0;\n" " size_t dec_len = 0;\n"
" boolean use_default = p_td.json->default_value && 0 == p_tok.get_buffer_length();\n" " boolean use_default = p_td.json->default_value && 0 == p_tok.get_buffer_length();\n"
" if (use_default) {\n" " if (use_default) {\n"
// No JSON data in the buffer -> use default value // No JSON data in the buffer -> use default value
...@@ -843,7 +843,7 @@ void defEnumClass(const enum_def *edef, output_struct *output) ...@@ -843,7 +843,7 @@ void defEnumClass(const enum_def *edef, output_struct *output)
" enum_value = %s;\n" " enum_value = %s;\n"
" return JSON_ERROR_FATAL;\n" " return JSON_ERROR_FATAL;\n"
" }\n" " }\n"
" return dec_len;\n" " return (int)dec_len;\n"
"}\n\n" "}\n\n"
, name, unknown_value, unbound_value, unbound_value); , name, unknown_value, unbound_value, unbound_value);
} }
......
...@@ -4419,7 +4419,7 @@ void defRecordClass1(const struct_def *sdef, output_struct *output) ...@@ -4419,7 +4419,7 @@ void defRecordClass1(const struct_def *sdef, output_struct *output)
"int %s::JSON_decode(const TTCN_Typedescriptor_t&, JSON_Tokenizer& p_tok, boolean p_silent)\n" "int %s::JSON_decode(const TTCN_Typedescriptor_t&, JSON_Tokenizer& p_tok, boolean p_silent)\n"
"{\n" "{\n"
" json_token_t j_token = JSON_TOKEN_NONE;\n" " json_token_t j_token = JSON_TOKEN_NONE;\n"
" int dec_len = p_tok.get_next_token(&j_token, NULL, NULL);\n" " size_t dec_len = p_tok.get_next_token(&j_token, NULL, NULL);\n"
" if (JSON_TOKEN_ERROR == j_token) {\n" " if (JSON_TOKEN_ERROR == j_token) {\n"
" JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_BAD_TOKEN_ERROR, \"\");\n" " JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_BAD_TOKEN_ERROR, \"\");\n"
" return JSON_ERROR_FATAL;\n" " return JSON_ERROR_FATAL;\n"
...@@ -4533,7 +4533,7 @@ void defRecordClass1(const struct_def *sdef, output_struct *output) ...@@ -4533,7 +4533,7 @@ void defRecordClass1(const struct_def *sdef, output_struct *output)
" }\n" " }\n"
" return JSON_ERROR_FATAL;\n" " return JSON_ERROR_FATAL;\n"
" }\n" " }\n"
" dec_len += ret_val;\n" " dec_len += (size_t)ret_val;\n"
, sdef->elements[i].dispname); , sdef->elements[i].dispname);
if (has_metainfo_enabled) { if (has_metainfo_enabled) {
src = mputstr(src, " }\n"); src = mputstr(src, " }\n");
...@@ -4603,7 +4603,7 @@ void defRecordClass1(const struct_def *sdef, output_struct *output) ...@@ -4603,7 +4603,7 @@ void defRecordClass1(const struct_def *sdef, output_struct *output)
" }\n"); " }\n");
} }
src = mputstr(src, src = mputstr(src,
"\n return dec_len;\n" "\n return (int)dec_len;\n"
"}\n\n"); "}\n\n");
} }
...@@ -6093,7 +6093,7 @@ static void defEmptyRecordClass(const struct_def *sdef, ...@@ -6093,7 +6093,7 @@ static void defEmptyRecordClass(const struct_def *sdef,
"int %s::JSON_decode(const TTCN_Typedescriptor_t&, JSON_Tokenizer& p_tok, boolean p_silent)\n" "int %s::JSON_decode(const TTCN_Typedescriptor_t&, JSON_Tokenizer& p_tok, boolean p_silent)\n"
"{\n" "{\n"
" json_token_t token = JSON_TOKEN_NONE;\n" " json_token_t token = JSON_TOKEN_NONE;\n"
" int dec_len = p_tok.get_next_token(&token, NULL, NULL);\n" " size_t dec_len = p_tok.get_next_token(&token, NULL, NULL);\n"
" if (JSON_TOKEN_ERROR == token) {\n" " if (JSON_TOKEN_ERROR == token) {\n"
" JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_BAD_TOKEN_ERROR, \"\");\n" " JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_BAD_TOKEN_ERROR, \"\");\n"
" return JSON_ERROR_FATAL;\n" " return JSON_ERROR_FATAL;\n"
...@@ -6107,7 +6107,7 @@ static void defEmptyRecordClass(const struct_def *sdef, ...@@ -6107,7 +6107,7 @@ static void defEmptyRecordClass(const struct_def *sdef,
" return JSON_ERROR_FATAL;\n" " return JSON_ERROR_FATAL;\n"
" }\n\n" " }\n\n"
" bound_flag = TRUE;\n\n" " bound_flag = TRUE;\n\n"
" return dec_len;\n" " return (int)dec_len;\n"
"}\n\n" "}\n\n"
, name); , name);
} }
......
...@@ -1139,7 +1139,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output) ...@@ -1139,7 +1139,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
" if (own_tag)"); " if (own_tag)");
} }
src=mputprintf(src, src=mputprintf(src,
" {\n" /* Do empty element tag */ " {\n" /* Do empty element tag */
"%s" "%s"
" p_buf.put_c('<');\n" " p_buf.put_c('<');\n"
" if (e_xer) write_ns_prefix(p_td, p_buf);\n" " if (e_xer) write_ns_prefix(p_td, p_buf);\n"
...@@ -1327,7 +1327,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output) ...@@ -1327,7 +1327,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
, force_gen_seof ? " && (p_td.xer_bits & XER_ATTRIBUTE)" : ""); , force_gen_seof ? " && (p_td.xer_bits & XER_ATTRIBUTE)" : "");
} }
src=mputstr(src, src=mputstr(src,
" if (own_tag){\n" " if (own_tag) {\n"
" p_buf.put_c('<');\n" " p_buf.put_c('<');\n"
" p_buf.put_c('/');\n" " p_buf.put_c('/');\n"
" if (e_xer) write_ns_prefix(p_td, p_buf);\n" " if (e_xer) write_ns_prefix(p_td, p_buf);\n"
...@@ -1565,7 +1565,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output) ...@@ -1565,7 +1565,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
"int %s::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_tok, boolean p_silent)\n" "int %s::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_tok, boolean p_silent)\n"
"{\n" "{\n"
" json_token_t token = JSON_TOKEN_NONE;\n" " json_token_t token = JSON_TOKEN_NONE;\n"
" int dec_len = p_tok.get_next_token(&token, NULL, NULL);\n" " size_t dec_len = p_tok.get_next_token(&token, NULL, NULL);\n"
" if (JSON_TOKEN_ERROR == token) {\n" " if (JSON_TOKEN_ERROR == token) {\n"
" JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_BAD_TOKEN_ERROR, \"\");\n" " JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_BAD_TOKEN_ERROR, \"\");\n"
" return JSON_ERROR_FATAL;\n" " return JSON_ERROR_FATAL;\n"
...@@ -1576,7 +1576,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output) ...@@ -1576,7 +1576,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
" set_size(0);\n" " set_size(0);\n"
" for (int nof_elements = 0; TRUE; ++nof_elements) {\n" " for (int nof_elements = 0; TRUE; ++nof_elements) {\n"
" size_t buf_pos = p_tok.get_buf_pos();\n" " size_t buf_pos = p_tok.get_buf_pos();\n"
" int ret_val;\n" " size_t ret_val;\n"
" if (NULL != p_td.json && p_td.json->metainfo_unbound) {\n" " if (NULL != p_td.json && p_td.json->metainfo_unbound) {\n"
// check for metainfo object // check for metainfo object
" ret_val = p_tok.get_next_token(&token, NULL, NULL);\n" " ret_val = p_tok.get_next_token(&token, NULL, NULL);\n"
...@@ -1601,13 +1601,13 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output) ...@@ -1601,13 +1601,13 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
" p_tok.set_buf_pos(buf_pos);\n" " p_tok.set_buf_pos(buf_pos);\n"
" }\n" " }\n"
" %s* val = new %s;\n" " %s* val = new %s;\n"
" ret_val = val->JSON_decode(*p_td.oftype_descr, p_tok, p_silent);\n" " int ret_val2 = val->JSON_decode(*p_td.oftype_descr, p_tok, p_silent);\n"
" if (JSON_ERROR_INVALID_TOKEN == ret_val) {\n" " if (JSON_ERROR_INVALID_TOKEN == ret_val2) {\n"
" p_tok.set_buf_pos(buf_pos);\n" " p_tok.set_buf_pos(buf_pos);\n"
" delete val;\n" " delete val;\n"
" break;\n" " break;\n"
" }\n" " }\n"
" else if (JSON_ERROR_FATAL == ret_val) {\n" " else if (JSON_ERROR_FATAL == ret_val2) {\n"
" delete val;\n" " delete val;\n"
" if (p_silent) {\n" " if (p_silent) {\n"
" clean_up();\n" " clean_up();\n"
...@@ -1618,7 +1618,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output) ...@@ -1618,7 +1618,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
" (void**)val_ptr->value_elements, val_ptr->n_elements, nof_elements + 1);\n" " (void**)val_ptr->value_elements, val_ptr->n_elements, nof_elements + 1);\n"
" val_ptr->value_elements[nof_elements] = val;\n" " val_ptr->value_elements[nof_elements] = val;\n"
" val_ptr->n_elements = nof_elements + 1;\n" " val_ptr->n_elements = nof_elements + 1;\n"
" dec_len += ret_val;\n" " dec_len += (size_t)ret_val2;\n"
" }\n\n" " }\n\n"
" dec_len += p_tok.get_next_token(&token, NULL, NULL);\n" " dec_len += p_tok.get_next_token(&token, NULL, NULL);\n"
" if (JSON_TOKEN_ARRAY_END != token) {\n" " if (JSON_TOKEN_ARRAY_END != token) {\n"
...@@ -1628,7 +1628,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output) ...@@ -1628,7 +1628,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
" }\n" " }\n"
" return JSON_ERROR_FATAL;\n" " return JSON_ERROR_FATAL;\n"
" }\n\n" " }\n\n"
" return dec_len;\n" " return (int)dec_len;\n"
"}\n\n" "}\n\n"
, name, type, type, type); , name, type, type, type);
} }
...@@ -2607,7 +2607,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct ...@@ -2607,7 +2607,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
" if (own_tag)"); " if (own_tag)");
} }
src=mputprintf(src, src=mputprintf(src,
" {\n" /* Do empty element tag */ " {\n" /* Do empty element tag */
"%s" "%s"
" p_buf.put_c('<');\n" " p_buf.put_c('<');\n"
" if (e_xer) write_ns_prefix(p_td, p_buf);\n" " if (e_xer) write_ns_prefix(p_td, p_buf);\n"
...@@ -2790,7 +2790,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct ...@@ -2790,7 +2790,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
, force_gen_seof ? " && (p_td.xer_bits & XER_ATTRIBUTE)" : ""); , force_gen_seof ? " && (p_td.xer_bits & XER_ATTRIBUTE)" : "");
} }
src=mputstr(src, src=mputstr(src,
" if (own_tag){\n" " if (own_tag) {\n"
" p_buf.put_c('<');\n" " p_buf.put_c('<');\n"
" p_buf.put_c('/');\n" " p_buf.put_c('/');\n"
" if (e_xer) write_ns_prefix(p_td, p_buf);\n" " if (e_xer) write_ns_prefix(p_td, p_buf);\n"
...@@ -3017,7 +3017,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct ...@@ -3017,7 +3017,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
"int %s::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_tok, boolean p_silent)\n" "int %s::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_tok, boolean p_silent)\n"
"{\n" "{\n"
" json_token_t token = JSON_TOKEN_NONE;\n" " json_token_t token = JSON_TOKEN_NONE;\n"
" int dec_len = p_tok.get_next_token(&token, NULL, NULL);\n" " size_t dec_len = p_tok.get_next_token(&token, NULL, NULL);\n"
" if (JSON_TOKEN_ERROR == token) {\n" " if (JSON_TOKEN_ERROR == token) {\n"
" JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_BAD_TOKEN_ERROR, \"\");\n" " JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_BAD_TOKEN_ERROR, \"\");\n"
" return JSON_ERROR_FATAL;\n" " return JSON_ERROR_FATAL;\n"
...@@ -3028,7 +3028,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct ...@@ -3028,7 +3028,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
" set_size(0);\n" " set_size(0);\n"
" for (int nof_elements = 0; TRUE; ++nof_elements) {\n" " for (int nof_elements = 0; TRUE; ++nof_elements) {\n"
" size_t buf_pos = p_tok.get_buf_pos();\n" " size_t buf_pos = p_tok.get_buf_pos();\n"
" int ret_val;\n" " size_t ret_val;\n"
" if (NULL != p_td.json && p_td.json->metainfo_unbound) {\n" " if (NULL != p_td.json && p_td.json->metainfo_unbound) {\n"
// check for metainfo object // check for metainfo object
" ret_val = p_tok.get_next_token(&token, NULL, NULL);\n" " ret_val = p_tok.get_next_token(&token, NULL, NULL);\n"
...@@ -3053,12 +3053,12 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct ...@@ -3053,12 +3053,12 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
" p_tok.set_buf_pos(buf_pos);\n" " p_tok.set_buf_pos(buf_pos);\n"
" }\n" " }\n"
" %s val;\n" " %s val;\n"
" ret_val = val.JSON_decode(*p_td.oftype_descr, p_tok, p_silent);\n" " int ret_val2 = val.JSON_decode(*p_td.oftype_descr, p_tok, p_silent);\n"
" if (JSON_ERROR_INVALID_TOKEN == ret_val) {\n" " if (JSON_ERROR_INVALID_TOKEN == ret_val2) {\n"
" p_tok.set_buf_pos(buf_pos);\n" " p_tok.set_buf_pos(buf_pos);\n"
" break;\n" " break;\n"
" }\n" " }\n"
" else if (JSON_ERROR_FATAL == ret_val) {\n" " else if (JSON_ERROR_FATAL == ret_val2) {\n"
" if (p_silent) {\n" " if (p_silent) {\n"
" clean_up();\n" " clean_up();\n"
" }\n" " }\n"
...@@ -3066,7 +3066,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct ...@@ -3066,7 +3066,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
" }\n" " }\n"
" set_size(nof_elements + 1);\n" " set_size(nof_elements + 1);\n"
" value_elements[nof_elements] = val;\n" " value_elements[nof_elements] = val;\n"
" dec_len += ret_val;\n" " dec_len += (size_t)ret_val2;\n"
" }\n\n" " }\n\n"
" dec_len += p_tok.get_next_token(&token, NULL, NULL);\n" " dec_len += p_tok.get_next_token(&token, NULL, NULL);\n"
" if (JSON_TOKEN_ARRAY_END != token) {\n" " if (JSON_TOKEN_ARRAY_END != token) {\n"
...@@ -3076,7 +3076,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct ...@@ -3076,7 +3076,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
" }\n" " }\n"
" return JSON_ERROR_FATAL;\n" " return JSON_ERROR_FATAL;\n"
" }\n\n" " }\n\n"
" return dec_len;\n" " return (int)dec_len;\n"
"}\n\n" "}\n\n"
, name, type); , name, type);
} }
......
...@@ -1379,7 +1379,7 @@ void defUnionClass(struct_def const *sdef, output_struct *output) ...@@ -1379,7 +1379,7 @@ void defUnionClass(struct_def const *sdef, output_struct *output)
if (sdef->xerUseUnion || i > 0) src = mputprintf(src, if (sdef->xerUseUnion || i > 0) src = mputprintf(src,
" need_type = (%s_xer_.namelens[1] > 2) || %s_xer_.xsd_type != XSD_NONE;\n" " need_type = (%s_xer_.namelens[1] > 2) || %s_xer_.xsd_type != XSD_NONE;\n"
, sdef->elements[i].typegen , sdef->elements[i].typegen
, sdef->elements[i].typegen); , sdef->elements[i].typegen);
src = mputstr(src, " break;\n"); src = mputstr(src, " break;\n");
} }
...@@ -1459,18 +1459,18 @@ void defUnionClass(struct_def const *sdef, output_struct *output) ...@@ -1459,18 +1459,18 @@ void defUnionClass(struct_def const *sdef, output_struct *output)
, selection_prefix, sdef->elements[i].name); , selection_prefix, sdef->elements[i].name);
if (!sdef->xerUseUnion) { // UseType if (!sdef->xerUseUnion) { // UseType
src = mputprintf(src, src = mputprintf(src,
" if (%s_xer_.my_module != 0 && %s_xer_.ns_index != -1 &&\n" " if (%s_xer_.my_module != 0 && %s_xer_.ns_index != -1 &&\n"
" %s_xer_.namelens[1] > 2) {\n" " %s_xer_.namelens[1] > 2) {\n"
/* add the namespace prefix to the type attribute (if the name is not empty) */ /* add the namespace prefix to the type attribute (if the name is not empty) */
" const namespace_t *my_ns = %s_xer_.my_module->get_ns(%s_xer_.ns_index);\n" " const namespace_t *my_ns = %s_xer_.my_module->get_ns(%s_xer_.ns_index);\n"
" if (my_ns->px[0] != 0) {\n" " if (my_ns->px[0] != 0) {\n"
" type_name = mprintf(\"%%s:\", my_ns->px);\n" " type_name = mprintf(\"%%s:\", my_ns->px);\n"
" }\n" " }\n"
" }\n" " }\n"
" type_name = mputstrn(type_name, %s_xer_.names[1], %s_xer_.namelens[1] - 2);\n" " type_name = mputstrn(type_name, %s_xer_.names[1], %s_xer_.namelens[1] - 2);\n"
, sdef->elements[i].typegen, sdef->elements[i].typegen , sdef->elements[i].typegen, sdef->elements[i].typegen
, sdef->elements[i].typegen, sdef->elements[i].typegen , sdef->elements[i].typegen, sdef->elements[i].typegen
, sdef->elements[i].typegen, sdef->elements[i].typegen , sdef->elements[i].typegen, sdef->elements[i].typegen
, sdef->elements[i].typegen); , sdef->elements[i].typegen);
} }
if (sdef->elements[i].xsd_type != XSD_NONE) { if (sdef->elements[i].xsd_type != XSD_NONE) {
...@@ -1600,18 +1600,18 @@ void defUnionClass(struct_def const *sdef, output_struct *output) ...@@ -1600,18 +1600,18 @@ void defUnionClass(struct_def const *sdef, output_struct *output)
, selection_prefix, sdef->elements[i].name); , selection_prefix, sdef->elements[i].name);
if (!sdef->xerUseUnion) { // UseType if (!sdef->xerUseUnion) { // UseType
src = mputprintf(src, src = mputprintf(src,
" if (%s_xer_.my_module != 0 && %s_xer_.ns_index != -1 &&\n" " if (%s_xer_.my_module != 0 && %s_xer_.ns_index != -1 &&\n"
" %s_xer_.namelens[1] > 2) {\n" " %s_xer_.namelens[1] > 2) {\n"
/* add the namespace prefix to the type attribute (if the name is not empty) */ /* add the namespace prefix to the type attribute (if the name is not empty) */
" const namespace_t *my_ns = %s_xer_.my_module->get_ns(%s_xer_.ns_index);\n" " const namespace_t *my_ns = %s_xer_.my_module->get_ns(%s_xer_.ns_index);\n"
" if (my_ns->px[0] != 0) {\n" " if (my_ns->px[0] != 0) {\n"
" type_name = mprintf(\"%%s:\", my_ns->px);\n" " type_name = mprintf(\"%%s:\", my_ns->px);\n"
" }\n" " }\n"
" }\n" " }\n"
" type_name = mputstrn(type_name, %s_xer_.names[1], %s_xer_.namelens[1] - 2);\n" " type_name = mputstrn(type_name, %s_xer_.names[1], %s_xer_.namelens[1] - 2);\n"
, sdef->elements[i].typegen, sdef->elements[i].typegen , sdef->elements[i].typegen, sdef->elements[i].typegen
, sdef->elements[i].typegen, sdef->elements[i].typegen , sdef->elements[i].typegen, sdef->elements[i].typegen
, sdef->elements[i].typegen, sdef->elements[i].typegen , sdef->elements[i].typegen, sdef->elements[i].typegen
, sdef->elements[i].typegen); , sdef->elements[i].typegen);
} }
if (sdef->elements[i].xsd_type != XSD_NONE) { if (sdef->elements[i].xsd_type != XSD_NONE) {
...@@ -2205,7 +2205,7 @@ void defUnionClass(struct_def const *sdef, output_struct *output) ...@@ -2205,7 +2205,7 @@ void defUnionClass(struct_def const *sdef, output_struct *output)
"}\n\n"); "}\n\n");
} else { // not "as value" } else { // not "as value"
src = mputprintf(src, src = mputprintf(src,
" int dec_len = p_tok.get_next_token(&j_token, NULL, NULL);\n" " size_t dec_len = p_tok.get_next_token(&j_token, NULL, NULL);\n"
" if (JSON_TOKEN_ERROR == j_token) {\n" " if (JSON_TOKEN_ERROR == j_token) {\n"
" JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_BAD_TOKEN_ERROR, \"\");\n" " JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_BAD_TOKEN_ERROR, \"\");\n"
" return JSON_ERROR_FATAL;\n" " return JSON_ERROR_FATAL;\n"
...@@ -2232,7 +2232,7 @@ void defUnionClass(struct_def const *sdef, output_struct *output) ...@@ -2232,7 +2232,7 @@ void defUnionClass(struct_def const *sdef, output_struct *output)
" }\n" " }\n"
" return JSON_ERROR_FATAL;\n" " return JSON_ERROR_FATAL;\n"
" } else {\n" " } else {\n"
" dec_len += ret_val;\n" " dec_len += (size_t)ret_val;\n"
" }\n" " }\n"
" } else " " } else "
, sdef->elements[i].jsonAlias ? sdef->elements[i].jsonAlias : sdef->elements[i].dispname , sdef->elements[i].jsonAlias ? sdef->elements[i].jsonAlias : sdef->elements[i].dispname
...@@ -2252,7 +2252,7 @@ void defUnionClass(struct_def const *sdef, output_struct *output) ...@@ -2252,7 +2252,7 @@ void defUnionClass(struct_def const *sdef, output_struct *output)
" JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_STATIC_OBJECT_END_TOKEN_ERROR, \"\");\n" " JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_STATIC_OBJECT_END_TOKEN_ERROR, \"\");\n"
" return JSON_ERROR_FATAL;\n" " return JSON_ERROR_FATAL;\n"
" }\n\n" " }\n\n"
" return dec_len;\n" " return (int)dec_len;\n"
"}\n\n"); "}\n\n");
} }
} }
......
...@@ -307,7 +307,7 @@ int ASN_NULL::JSON_encode(const TTCN_Typedescriptor_t&, JSON_Tokenizer& p_tok) c ...@@ -307,7 +307,7 @@ int ASN_NULL::JSON_encode(const TTCN_Typedescriptor_t&, JSON_Tokenizer& p_tok) c
int ASN_NULL::JSON_decode(const TTCN_Typedescriptor_t&, JSON_Tokenizer& p_tok, boolean p_silent) int ASN_NULL::JSON_decode(const TTCN_Typedescriptor_t&, JSON_Tokenizer& p_tok, boolean p_silent)
{ {
json_token_t token = JSON_TOKEN_NONE; json_token_t token = JSON_TOKEN_NONE;
int dec_len = p_tok.get_next_token(&token, NULL, NULL); size_t dec_len = p_tok.get_next_token(&token, NULL, NULL);
if (JSON_TOKEN_ERROR == token) { if (JSON_TOKEN_ERROR == token) {
JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_BAD_TOKEN_ERROR, ""); JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_BAD_TOKEN_ERROR, "");
return JSON_ERROR_FATAL; return JSON_ERROR_FATAL;
...@@ -316,7 +316,7 @@ int ASN_NULL::JSON_decode(const TTCN_Typedescriptor_t&, JSON_Tokenizer& p_tok, b ...@@ -316,7 +316,7 @@ int ASN_NULL::JSON_decode(const TTCN_Typedescriptor_t&, JSON_Tokenizer& p_tok, b
return JSON_ERROR_INVALID_TOKEN; return JSON_ERROR_INVALID_TOKEN;
} }
bound_flag = TRUE; bound_flag = TRUE;
return dec_len; return (int)dec_len;
} }
boolean operator==(asn_null_type, const ASN_NULL& other_value) boolean operator==(asn_null_type, const ASN_NULL& other_value)
......
...@@ -549,7 +549,7 @@ int VALUE_ARRAY<T_type,array_size,index_offset>::JSON_decode( ...@@ -549,7 +549,7 @@ int VALUE_ARRAY<T_type,array_size,index_offset>::JSON_decode(
const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_tok, boolean p_silent) const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_tok, boolean p_silent)
{ {
json_token_t token = JSON_TOKEN_NONE; json_token_t token = JSON_TOKEN_NONE;
int dec_len = p_tok.get_next_token(&token, NULL, NULL); size_t dec_len = p_tok.get_next_token(&token, NULL, NULL);
if (JSON_TOKEN_ERROR == token) { if (JSON_TOKEN_ERROR == token) {
JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_BAD_TOKEN_ERROR, ""); JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_BAD_TOKEN_ERROR, "");
return JSON_ERROR_FATAL; return JSON_ERROR_FATAL;
...@@ -560,7 +560,7 @@ int VALUE_ARRAY<T_type,array_size,index_offset>::JSON_decode( ...@@ -560,7 +560,7 @@ int VALUE_ARRAY<T_type,array_size,index_offset>::JSON_decode(
for (unsigned int i = 0; i < array_size; ++i) { for (unsigned int i = 0; i < array_size; ++i) {
size_t buf_pos = p_tok.get_buf_pos(); size_t buf_pos = p_tok.get_buf_pos();
int ret_val; size_t ret_val;
if (NULL != p_td.json && p_td.json->metainfo_unbound) { if (NULL != p_td.json && p_td.json->metainfo_unbound) {
// check for metainfo object // check for metainfo object
ret_val = p_tok.get_next_token(&token, NULL, NULL); ret_val = p_tok.get_next_token(&token, NULL, NULL);
...@@ -584,19 +584,19 @@ int VALUE_ARRAY<T_type,array_size,index_offset>::JSON_decode( ...@@ -584,19 +584,19 @@ int VALUE_ARRAY<T_type,array_size,index_offset>::JSON_decode(
// metainfo object not found, jump back and let the element type decode it // metainfo object not found, jump back and let the element type decode it
p_tok.set_buf_pos(buf_pos); p_tok.set_buf_pos(buf_pos);
} }
ret_val = array_elements[i].JSON_decode(*get_elem_descr(), p_tok, p_silent); int ret_val2 = array_elements[i].JSON_decode(*get_elem_descr(), p_tok, p_silent);
if (JSON_ERROR_INVALID_TOKEN == ret_val) { if (JSON_ERROR_INVALID_TOKEN == ret_val2) {
JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_ARRAY_ELEM_TOKEN_ERROR, JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_ARRAY_ELEM_TOKEN_ERROR,
array_size - i, (array_size - i > 1) ? "s" : ""); array_size - i, (array_size - i > 1) ? "s" : "");
return JSON_ERROR_FATAL; return JSON_ERROR_FATAL;
} }
else if (JSON_ERROR_FATAL == ret_val) { else if (JSON_ERROR_FATAL == ret_val2) {
if (p_silent) { if (p_silent) {
clean_up(); clean_up();
} }
return JSON_ERROR_FATAL; return JSON_ERROR_FATAL;
} }
dec_len += ret_val; dec_len += (size_t)ret_val2;
} }
dec_len += p_tok.get_next_token(&token, NULL, NULL); dec_len += p_tok.get_next_token(&token, NULL, NULL);
......
...@@ -1189,7 +1189,7 @@ int BITSTRING::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_ ...@@ -1189,7 +1189,7 @@ int BITSTRING::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_
char* value = 0; char* value = 0;
size_t value_len = 0; size_t value_len = 0;
boolean error = FALSE; boolean error = FALSE;
int dec_len = 0; size_t dec_len = 0;
boolean use_default = p_td.json->default_value && 0 == p_tok.get_buffer_length(); boolean use_default = p_td.json->default_value && 0 == p_tok.get_buffer_length();
if (use_default) { if (use_default) {
// No JSON data in the buffer -> use default value // No JSON data in the buffer -> use default value
...@@ -1232,7 +1232,7 @@ int BITSTRING::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_ ...@@ -1232,7 +1232,7 @@ int BITSTRING::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_
} }
return JSON_ERROR_FATAL; return JSON_ERROR_FATAL;
} }
return dec_len; return (int)dec_len;
} }
......
...@@ -746,7 +746,7 @@ int BOOLEAN::JSON_encode(const TTCN_Typedescriptor_t&, JSON_Tokenizer& p_tok) co ...@@ -746,7 +746,7 @@ int BOOLEAN::JSON_encode(const TTCN_Typedescriptor_t&, JSON_Tokenizer& p_tok) co
int BOOLEAN::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_tok, boolean p_silent) int BOOLEAN::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_tok, boolean p_silent)
{ {
json_token_t token = JSON_TOKEN_NONE; json_token_t token = JSON_TOKEN_NONE;
int dec_len = 0; size_t dec_len = 0;
if (p_td.json->default_value && 0 == p_tok.get_buffer_length()) { if (p_td.json->default_value && 0 == p_tok.get_buffer_length()) {
// No JSON data in the buffer -> use default value // No JSON data in the buffer -> use default value
if (strcmp(p_td.json->default_value, "true") == 0) { if (strcmp(p_td.json->default_value, "true") == 0) {
...@@ -774,7 +774,7 @@ int BOOLEAN::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_to ...@@ -774,7 +774,7 @@ int BOOLEAN::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_to
bound_flag = FALSE; bound_flag = FALSE;
return JSON_ERROR_INVALID_TOKEN; return JSON_ERROR_INVALID_TOKEN;
} }
return dec_len; return (int)dec_len;
} }
......
...@@ -1733,7 +1733,7 @@ int CHARSTRING::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p ...@@ -1733,7 +1733,7 @@ int CHARSTRING::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p
json_token_t token = JSON_TOKEN_NONE; json_token_t token = JSON_TOKEN_NONE;
char* value = 0; char* value = 0;
size_t value_len = 0; size_t value_len = 0;
int dec_len = 0; size_t dec_len = 0;
boolean use_default = p_td.json->default_value && 0 == p_tok.get_buffer_length(); boolean use_default = p_td.json->default_value && 0 == p_tok.get_buffer_length();
if (use_default) { if (use_default