diff --git a/app/src/json/json_parser.c b/app/src/json/json_parser.c index 65ce9a7..690d545 100644 --- a/app/src/json/json_parser.c +++ b/app/src/json/json_parser.c @@ -112,10 +112,6 @@ parser_error_t array_get_nth_element(const parsed_json_t *json, uint16_t array_token_index, uint16_t element_index, uint16_t *token_index) { - if (array_token_index < 0 || array_token_index > json->numberOfTokens) { - return parser_no_data; - } - jsmntok_t array_token = json->tokens[array_token_index]; *token_index = array_token_index; @@ -147,10 +143,6 @@ parser_error_t object_get_element_count(const parsed_json_t *json, uint16_t object_token_index, uint16_t *element_count) { *element_count = 0; - if (object_token_index < 0 || object_token_index > json->numberOfTokens) { - return parser_no_data; - } - jsmntok_t object_token = json->tokens[object_token_index]; uint16_t token_index = object_token_index; uint16_t prev_element_end = object_token.start; @@ -179,10 +171,6 @@ parser_error_t object_get_nth_key(const parsed_json_t *json, uint16_t object_element_index, uint16_t *token_index) { *token_index = object_token_index; - if (object_token_index < 0 || object_token_index > json->numberOfTokens) { - return parser_no_data; - } - jsmntok_t object_token = json->tokens[object_token_index]; uint16_t element_count = 0; uint16_t prev_element_end = object_token.start; @@ -214,10 +202,6 @@ parser_error_t object_get_nth_value(const parsed_json_t *json, uint16_t object_token_index, uint16_t object_element_index, uint16_t *key_index) { - if (object_token_index < 0 || object_token_index > json->numberOfTokens) { - return parser_no_data; - } - CHECK_PARSER_ERR(object_get_nth_key(json, object_token_index, object_element_index, key_index)) (*key_index)++; @@ -228,10 +212,6 @@ parser_error_t object_get_value(const parsed_json_t *json, uint16_t object_token_index, const char *key_name, uint16_t *token_index) { - if (object_token_index < 0 || object_token_index > json->numberOfTokens) { - return parser_no_data; - } - const jsmntok_t object_token = json->tokens[object_token_index]; *token_index = object_token_index; diff --git a/app/src/tx_display.c b/app/src/tx_display.c index 87dc5fd..1b5e6d5 100644 --- a/app/src/tx_display.c +++ b/app/src/tx_display.c @@ -15,7 +15,6 @@ ********************************************************************************/ #ifdef __cplusplus #pragma clang diagnostic push -#pragma ide diagnostic ignored "misc-no-recursion" #endif #include "coin.h" @@ -58,7 +57,6 @@ const char *get_required_root_item(root_item_e i) { #ifdef __cplusplus #pragma clang diagnostic push -#pragma ide diagnostic ignored "bugprone-branch-clone" #endif __Z_INLINE uint8_t get_root_max_level(root_item_e i) { diff --git a/app/src/tx_parser.h b/app/src/tx_parser.h index 2bebc3a..c4473f0 100644 --- a/app/src/tx_parser.h +++ b/app/src/tx_parser.h @@ -17,7 +17,6 @@ #ifdef __cplusplus #pragma clang diagnostic push -#pragma ide diagnostic ignored "modernize-deprecated-headers" #endif #include "json/json_parser.h" diff --git a/app/src/tx_validate.c b/app/src/tx_validate.c index 2eed930..df5446b 100644 --- a/app/src/tx_validate.c +++ b/app/src/tx_validate.c @@ -39,7 +39,7 @@ int8_t is_space(char c) { int8_t contains_whitespace(parsed_json_t *json) { if (json == NULL){ - return 1; + return 2; } int start = 0; @@ -132,10 +132,16 @@ int8_t dictionaries_sorted(parsed_json_t *json) { } parser_error_t tx_validate(parsed_json_t *json) { - if (contains_whitespace(json) == 1) { + int8_t whitespace_check = contains_whitespace(json); + + if (whitespace_check == 1) { return parser_json_contains_whitespace; } + if (whitespace_check == 2) { + return parser_json_unexpected_error; + } + if (dictionaries_sorted(json) != 1) { return parser_json_is_not_sorted; }