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)
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;
*p_token = JSON_TOKEN_NONE;
......
......@@ -145,7 +145,7 @@ public:
* @return The number of characters extracted
* @note The token data is not copied, *p_token_str will point to the start of the
* 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.
* This is where get_next_token() will read from next. */
......
......@@ -810,7 +810,7 @@ void defEnumClass(const enum_def *edef, output_struct *output)
" char* value = 0;\n"
" size_t value_len = 0;\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"
" if (use_default) {\n"
// No JSON data in the buffer -> use default value
......@@ -843,7 +843,7 @@ void defEnumClass(const enum_def *edef, output_struct *output)
" enum_value = %s;\n"
" return JSON_ERROR_FATAL;\n"
" }\n"
" return dec_len;\n"
" return (int)dec_len;\n"
"}\n\n"
, name, unknown_value, unbound_value, unbound_value);
}
......
......@@ -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"
"{\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"
" JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_BAD_TOKEN_ERROR, \"\");\n"
" return JSON_ERROR_FATAL;\n"
......@@ -4533,7 +4533,7 @@ void defRecordClass1(const struct_def *sdef, output_struct *output)
" }\n"
" return JSON_ERROR_FATAL;\n"
" }\n"
" dec_len += ret_val;\n"
" dec_len += (size_t)ret_val;\n"
, sdef->elements[i].dispname);
if (has_metainfo_enabled) {
src = mputstr(src, " }\n");
......@@ -4603,7 +4603,7 @@ void defRecordClass1(const struct_def *sdef, output_struct *output)
" }\n");
}
src = mputstr(src,
"\n return dec_len;\n"
"\n return (int)dec_len;\n"
"}\n\n");
}
......@@ -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"
"{\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"
" JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_BAD_TOKEN_ERROR, \"\");\n"
" return JSON_ERROR_FATAL;\n"
......@@ -6107,7 +6107,7 @@ static void defEmptyRecordClass(const struct_def *sdef,
" return JSON_ERROR_FATAL;\n"
" }\n\n"
" bound_flag = TRUE;\n\n"
" return dec_len;\n"
" return (int)dec_len;\n"
"}\n\n"
, name);
}
......
......@@ -1139,7 +1139,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
" if (own_tag)");
}
src=mputprintf(src,
" {\n" /* Do empty element tag */
" {\n" /* Do empty element tag */
"%s"
" p_buf.put_c('<');\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)
, force_gen_seof ? " && (p_td.xer_bits & XER_ATTRIBUTE)" : "");
}
src=mputstr(src,
" if (own_tag){\n"
" if (own_tag) {\n"
" p_buf.put_c('<');\n"
" p_buf.put_c('/');\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)
"int %s::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_tok, boolean p_silent)\n"
"{\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"
" JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_BAD_TOKEN_ERROR, \"\");\n"
" return JSON_ERROR_FATAL;\n"
......@@ -1576,7 +1576,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
" set_size(0);\n"
" for (int nof_elements = 0; TRUE; ++nof_elements) {\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"
// check for metainfo object
" 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)
" p_tok.set_buf_pos(buf_pos);\n"
" }\n"
" %s* val = new %s;\n"
" ret_val = val->JSON_decode(*p_td.oftype_descr, p_tok, p_silent);\n"
" if (JSON_ERROR_INVALID_TOKEN == ret_val) {\n"
" int ret_val2 = val->JSON_decode(*p_td.oftype_descr, p_tok, p_silent);\n"
" if (JSON_ERROR_INVALID_TOKEN == ret_val2) {\n"
" p_tok.set_buf_pos(buf_pos);\n"
" delete val;\n"
" break;\n"
" }\n"
" else if (JSON_ERROR_FATAL == ret_val) {\n"
" else if (JSON_ERROR_FATAL == ret_val2) {\n"
" delete val;\n"
" if (p_silent) {\n"
" clean_up();\n"
......@@ -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"
" val_ptr->value_elements[nof_elements] = val;\n"
" val_ptr->n_elements = nof_elements + 1;\n"
" dec_len += ret_val;\n"
" dec_len += (size_t)ret_val2;\n"
" }\n\n"
" dec_len += p_tok.get_next_token(&token, NULL, NULL);\n"
" if (JSON_TOKEN_ARRAY_END != token) {\n"
......@@ -1628,7 +1628,7 @@ void defRecordOfClass1(const struct_of_def *sdef, output_struct *output)
" }\n"
" return JSON_ERROR_FATAL;\n"
" }\n\n"
" return dec_len;\n"
" return (int)dec_len;\n"
"}\n\n"
, name, type, type, type);
}
......@@ -2607,7 +2607,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
" if (own_tag)");
}
src=mputprintf(src,
" {\n" /* Do empty element tag */
" {\n" /* Do empty element tag */
"%s"
" p_buf.put_c('<');\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
, force_gen_seof ? " && (p_td.xer_bits & XER_ATTRIBUTE)" : "");
}
src=mputstr(src,
" if (own_tag){\n"
" if (own_tag) {\n"
" p_buf.put_c('<');\n"
" p_buf.put_c('/');\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
"int %s::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_tok, boolean p_silent)\n"
"{\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"
" JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_BAD_TOKEN_ERROR, \"\");\n"
" return JSON_ERROR_FATAL;\n"
......@@ -3028,7 +3028,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
" set_size(0);\n"
" for (int nof_elements = 0; TRUE; ++nof_elements) {\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"
// check for metainfo object
" ret_val = p_tok.get_next_token(&token, NULL, NULL);\n"
......@@ -3053,12 +3053,12 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
" p_tok.set_buf_pos(buf_pos);\n"
" }\n"
" %s val;\n"
" ret_val = val.JSON_decode(*p_td.oftype_descr, p_tok, p_silent);\n"
" if (JSON_ERROR_INVALID_TOKEN == ret_val) {\n"
" int ret_val2 = val.JSON_decode(*p_td.oftype_descr, p_tok, p_silent);\n"
" if (JSON_ERROR_INVALID_TOKEN == ret_val2) {\n"
" p_tok.set_buf_pos(buf_pos);\n"
" break;\n"
" }\n"
" else if (JSON_ERROR_FATAL == ret_val) {\n"
" else if (JSON_ERROR_FATAL == ret_val2) {\n"
" if (p_silent) {\n"
" clean_up();\n"
" }\n"
......@@ -3066,7 +3066,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
" }\n"
" set_size(nof_elements + 1);\n"
" value_elements[nof_elements] = val;\n"
" dec_len += ret_val;\n"
" dec_len += (size_t)ret_val2;\n"
" }\n\n"
" dec_len += p_tok.get_next_token(&token, NULL, NULL);\n"
" if (JSON_TOKEN_ARRAY_END != token) {\n"
......@@ -3076,7 +3076,7 @@ void defRecordOfClassMemAllocOptimized(const struct_of_def *sdef, output_struct
" }\n"
" return JSON_ERROR_FATAL;\n"
" }\n\n"
" return dec_len;\n"
" return (int)dec_len;\n"
"}\n\n"
, name, type);
}
......
......@@ -1379,7 +1379,7 @@ void defUnionClass(struct_def const *sdef, output_struct *output)
if (sdef->xerUseUnion || i > 0) src = mputprintf(src,
" 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);
src = mputstr(src, " break;\n");
}
......@@ -1459,18 +1459,18 @@ void defUnionClass(struct_def const *sdef, output_struct *output)
, selection_prefix, sdef->elements[i].name);
if (!sdef->xerUseUnion) { // UseType
src = mputprintf(src,
" if (%s_xer_.my_module != 0 && %s_xer_.ns_index != -1 &&\n"
" %s_xer_.namelens[1] > 2) {\n"
/* 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"
" if (my_ns->px[0] != 0) {\n"
" type_name = mprintf(\"%%s:\", my_ns->px);\n"
" }\n"
" }\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
" if (%s_xer_.my_module != 0 && %s_xer_.ns_index != -1 &&\n"
" %s_xer_.namelens[1] > 2) {\n"
/* 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"
" if (my_ns->px[0] != 0) {\n"
" type_name = mprintf(\"%%s:\", my_ns->px);\n"
" }\n"
" }\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);
}
if (sdef->elements[i].xsd_type != XSD_NONE) {
......@@ -1600,18 +1600,18 @@ void defUnionClass(struct_def const *sdef, output_struct *output)
, selection_prefix, sdef->elements[i].name);
if (!sdef->xerUseUnion) { // UseType
src = mputprintf(src,
" if (%s_xer_.my_module != 0 && %s_xer_.ns_index != -1 &&\n"
" %s_xer_.namelens[1] > 2) {\n"
/* 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"
" if (my_ns->px[0] != 0) {\n"
" type_name = mprintf(\"%%s:\", my_ns->px);\n"
" }\n"
" }\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
" if (%s_xer_.my_module != 0 && %s_xer_.ns_index != -1 &&\n"
" %s_xer_.namelens[1] > 2) {\n"
/* 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"
" if (my_ns->px[0] != 0) {\n"
" type_name = mprintf(\"%%s:\", my_ns->px);\n"
" }\n"
" }\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);
}
if (sdef->elements[i].xsd_type != XSD_NONE) {
......@@ -2205,7 +2205,7 @@ void defUnionClass(struct_def const *sdef, output_struct *output)
"}\n\n");
} else { // not "as value"
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"
" JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_BAD_TOKEN_ERROR, \"\");\n"
" return JSON_ERROR_FATAL;\n"
......@@ -2232,7 +2232,7 @@ void defUnionClass(struct_def const *sdef, output_struct *output)
" }\n"
" return JSON_ERROR_FATAL;\n"
" } else {\n"
" dec_len += ret_val;\n"
" dec_len += (size_t)ret_val;\n"
" }\n"
" } else "
, 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)
" JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_STATIC_OBJECT_END_TOKEN_ERROR, \"\");\n"
" return JSON_ERROR_FATAL;\n"
" }\n\n"
" return dec_len;\n"
" return (int)dec_len;\n"
"}\n\n");
}
}
......
......@@ -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)
{
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) {
JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_BAD_TOKEN_ERROR, "");
return JSON_ERROR_FATAL;
......@@ -316,7 +316,7 @@ int ASN_NULL::JSON_decode(const TTCN_Typedescriptor_t&, JSON_Tokenizer& p_tok, b
return JSON_ERROR_INVALID_TOKEN;
}
bound_flag = TRUE;
return dec_len;
return (int)dec_len;
}
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(
const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_tok, boolean p_silent)
{
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) {
JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_BAD_TOKEN_ERROR, "");
return JSON_ERROR_FATAL;
......@@ -560,7 +560,7 @@ int VALUE_ARRAY<T_type,array_size,index_offset>::JSON_decode(
for (unsigned int i = 0; i < array_size; ++i) {
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) {
// check for metainfo object
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(
// metainfo object not found, jump back and let the element type decode it
p_tok.set_buf_pos(buf_pos);
}
ret_val = array_elements[i].JSON_decode(*get_elem_descr(), p_tok, p_silent);
if (JSON_ERROR_INVALID_TOKEN == ret_val) {
int ret_val2 = array_elements[i].JSON_decode(*get_elem_descr(), p_tok, p_silent);
if (JSON_ERROR_INVALID_TOKEN == ret_val2) {
JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_ARRAY_ELEM_TOKEN_ERROR,
array_size - i, (array_size - i > 1) ? "s" : "");
return JSON_ERROR_FATAL;
}
else if (JSON_ERROR_FATAL == ret_val) {
else if (JSON_ERROR_FATAL == ret_val2) {
if (p_silent) {
clean_up();
}
return JSON_ERROR_FATAL;
}
dec_len += ret_val;
dec_len += (size_t)ret_val2;
}
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_
char* value = 0;
size_t value_len = 0;
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();
if (use_default) {
// 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_
}
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
int BOOLEAN::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_tok, boolean p_silent)
{
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()) {
// No JSON data in the buffer -> use default value
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
bound_flag = FALSE;
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
json_token_t token = JSON_TOKEN_NONE;
char* value = 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();
if (use_default) {
// No JSON data in the buffer -> use default value
......@@ -1755,7 +1755,7 @@ int CHARSTRING::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p
} else {
return JSON_ERROR_INVALID_TOKEN;
}
return dec_len;
return (int)dec_len;
}
......
......@@ -1111,7 +1111,7 @@ int FLOAT::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_tok,
json_token_t token = JSON_TOKEN_NONE;
char* value = 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();
if (use_default) {
// No JSON data in the buffer -> use default value
......@@ -1165,7 +1165,7 @@ int FLOAT::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_tok,
bound_flag = TRUE;
Free(value2);
}
return dec_len;
return (int)dec_len;
}
......
......@@ -1079,7 +1079,7 @@ int HEXSTRING::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_
char* value = 0;
size_t value_len = 0;
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();
if (use_default) {
// No JSON data in the buffer -> use default value
......@@ -1122,7 +1122,7 @@ int HEXSTRING::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_
}
return JSON_ERROR_FATAL;
}
return dec_len;
return (int)dec_len;
}
......
......@@ -1738,7 +1738,7 @@ int INTEGER::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_to
json_token_t token = JSON_TOKEN_NONE;
char* value = 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();
if (use_default) {
// No JSON data in the buffer -> use default value
......@@ -1765,7 +1765,7 @@ int INTEGER::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_to
bound_flag = FALSE;
return JSON_ERROR_INVALID_TOKEN;
}
return dec_len;
return (int)dec_len;
}
......@@ -2104,9 +2104,9 @@ boolean INTEGER_template::match(int other_value, boolean /* legacy */) const
// Lower boundary is set.
if (!lower_boundary) {
if (!value_range.min_is_exclusive) {
lower_boundary = (likely(value_range.min_value.native_flag) ?
int_val_t(value_range.min_value.val.native) :
int_val_t(BN_dup(value_range.min_value.val.openssl))) <= other_value;
lower_boundary = (likely(value_range.min_value.native_flag) ?
int_val_t(value_range.min_value.val.native) :
int_val_t(BN_dup(value_range.min_value.val.openssl))) <= other_value;
} else {
lower_boundary = (likely(value_range.min_value.native_flag) ?
int_val_t(value_range.min_value.val.native) :
......@@ -2116,9 +2116,9 @@ boolean INTEGER_template::match(int other_value, boolean /* legacy */) const
// Upper boundary is set.
if (!upper_boundary) {
if (!value_range.max_is_exclusive) {
upper_boundary = (likely(value_range.max_value.native_flag) ?
int_val_t(value_range.max_value.val.native) :
int_val_t(BN_dup(value_range.max_value.val.openssl))) >= other_value;
upper_boundary = (likely(value_range.max_value.native_flag) ?
int_val_t(value_range.max_value.val.native) :
int_val_t(BN_dup(value_range.max_value.val.openssl))) >= other_value;
} else {
upper_boundary = (likely(value_range.max_value.native_flag) ?
int_val_t(value_range.max_value.val.native) :
......@@ -2177,8 +2177,8 @@ boolean INTEGER_template::match(const INTEGER& other_value,
} else {
upper_boundary = (likely(value_range.max_value.native_flag) ?
int_val_t(value_range.max_value.val.native) :
int_val_t(BN_dup(value_range.max_value.val.openssl))) >= other_value.get_val();
}
int_val_t(BN_dup(value_range.max_value.val.openssl))) >= other_value.get_val();
}
}
return lower_boundary && upper_boundary; }
default:
......
......@@ -622,7 +622,7 @@ int OBJID::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_tok,
char* value = 0;
size_t value_len = 0;
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();
if (use_default) {
// No JSON data in the buffer -> use default value
......@@ -659,7 +659,7 @@ int OBJID::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_tok,
}
return JSON_ERROR_FATAL;
}
return dec_len;
return (int)dec_len;
}
void OBJID_template::clean_up()
......
......@@ -1302,7 +1302,7 @@ int OCTETSTRING::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer&
char* value = 0;
size_t value_len = 0;
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();
if (use_default) {
// No JSON data in the buffer -> use default value
......@@ -1348,7 +1348,7 @@ int OCTETSTRING::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer&
}
return JSON_ERROR_FATAL;
}
return dec_len;
return (int)dec_len;
}
// octetstring element class
......
......@@ -873,13 +873,13 @@ int OPTIONAL<T_type>::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokeni
// able to decode a "null" value
p_tok.set_buf_pos(buf_pos);
json_token_t token = JSON_TOKEN_NONE;
dec_len = p_tok.get_next_token(&token, NULL, NULL);
p_tok.get_next_token(&token, NULL, NULL);
if (JSON_TOKEN_LITERAL_NULL == token) {
set_to_omit();
}
else {
// cannot get JSON_TOKEN_ERROR here, that was already checked by the optional value
dec_len = JSON_ERROR_INVALID_TOKEN;
return JSON_ERROR_INVALID_TOKEN;
}
}
return dec_len;
......
......@@ -2536,7 +2536,7 @@ int UNIVERSAL_CHARSTRING::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_To
json_token_t token = JSON_TOKEN_NONE;
char* value = 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();
if (use_default) {
// No JSON data in the buffer -> use default value
......@@ -2567,7 +2567,7 @@ int UNIVERSAL_CHARSTRING::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_To
} else {
return JSON_ERROR_INVALID_TOKEN;
}
return dec_len;
return (int)dec_len;
}
......
......@@ -385,7 +385,7 @@ int VERDICTTYPE::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer&
json_token_t token = JSON_TOKEN_NONE;
char* value = 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();
if (use_default) {
// No JSON data in the buffer -> use default value
......@@ -417,14 +417,14 @@ int VERDICTTYPE::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer&
} else {
error = FALSE;
verdict_value = UNBOUND_VERDICT;
dec_len = JSON_ERROR_INVALID_TOKEN;
return JSON_ERROR_INVALID_TOKEN;
}
if (error) {
JSON_ERROR(TTCN_EncDec::ET_INVAL_MSG, JSON_DEC_FORMAT_ERROR, "string", "verdicttype");
verdict_value = UNBOUND_VERDICT;
dec_len = JSON_ERROR_FATAL;
return JSON_ERROR_FATAL;
}
return dec_len;