diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2018-07-02 23:38:48 -0700 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2018-07-18 11:37:03 +0000 |
commit | 354842fbc148e26677d99693793bf5f89f18a085 (patch) | |
tree | 0e3b216dad1f742feee7c79f73506fa75e94dc2b /src/3rdparty/tinycbor/src/cborparser.c | |
parent | 678b0cf6c3753ac72ca5c538cf24d70ff61c725d (diff) |
Update TinyCBOR to 1b233087a6e6b6be297e69bfcce5ed36f338c91d
From the fork at https://github.com/thiagomacieira/tinycbor
Change-Id: I117816bf0f5e469b8d34fffd153dc88683051208
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/3rdparty/tinycbor/src/cborparser.c')
-rw-r--r-- | src/3rdparty/tinycbor/src/cborparser.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/3rdparty/tinycbor/src/cborparser.c b/src/3rdparty/tinycbor/src/cborparser.c index 65b0b4b5c8..971230ea61 100644 --- a/src/3rdparty/tinycbor/src/cborparser.c +++ b/src/3rdparty/tinycbor/src/cborparser.c @@ -340,7 +340,7 @@ uint64_t _cbor_value_decode_int64_internal(const CborValue *value) * threads iterating at the same time, but the object can be copied so multiple * threads can iterate. */ -CborError cbor_parser_init(const uint8_t *buffer, size_t size, int flags, CborParser *parser, CborValue *it) +CborError cbor_parser_init(const uint8_t *buffer, size_t size, uint32_t flags, CborParser *parser, CborValue *it) { memset(parser, 0, sizeof(*parser)); parser->source.end = buffer + size; @@ -471,6 +471,9 @@ CborError cbor_value_advance_fixed(CborValue *it) static CborError advance_recursive(CborValue *it, int nestingLevel) { + CborError err; + CborValue recursed; + if (is_fixed_type(it->type)) return advance_internal(it); @@ -483,8 +486,6 @@ static CborError advance_recursive(CborValue *it, int nestingLevel) if (nestingLevel == 0) return CborErrorNestingTooDeep; - CborError err; - CborValue recursed; err = cbor_value_enter_container(it, &recursed); if (err) return err; @@ -810,8 +811,9 @@ CborError cbor_value_leave_container(CborValue *it, const CborValue *recursed) */ CborError cbor_value_get_int64_checked(const CborValue *value, int64_t *result) { + uint64_t v; cbor_assert(cbor_value_is_integer(value)); - uint64_t v = _cbor_value_extract_int64_helper(value); + v = _cbor_value_extract_int64_helper(value); /* Check before converting, as the standard says (C11 6.3.1.3 paragraph 3): * "[if] the new type is signed and the value cannot be represented in it; either the @@ -849,8 +851,9 @@ CborError cbor_value_get_int64_checked(const CborValue *value, int64_t *result) */ CborError cbor_value_get_int_checked(const CborValue *value, int *result) { + uint64_t v; cbor_assert(cbor_value_is_integer(value)); - uint64_t v = _cbor_value_extract_int64_helper(value); + v = _cbor_value_extract_int64_helper(value); /* Check before converting, as the standard says (C11 6.3.1.3 paragraph 3): * "[if] the new type is signed and the value cannot be represented in it; either the @@ -1177,13 +1180,12 @@ static uintptr_t iterate_memcpy(char *dest, const uint8_t *src, size_t len) static CborError iterate_string_chunks(const CborValue *value, char *buffer, size_t *buflen, bool *result, CborValue *next, IterateFunction func) { - cbor_assert(cbor_value_is_byte_string(value) || cbor_value_is_text_string(value)); - CborError err; CborValue tmp; size_t total = 0; const void *ptr; + cbor_assert(cbor_value_is_byte_string(value) || cbor_value_is_text_string(value)); if (!next) next = &tmp; *next = *value; @@ -1320,6 +1322,7 @@ CborError _cbor_value_copy_string(const CborValue *value, void *buffer, */ CborError cbor_value_text_string_equals(const CborValue *value, const char *string, bool *result) { + size_t len; CborValue copy = *value; CborError err = cbor_value_skip_tag(©); if (err) @@ -1329,7 +1332,7 @@ CborError cbor_value_text_string_equals(const CborValue *value, const char *stri return CborNoError; } - size_t len = strlen(string); + len = strlen(string); return iterate_string_chunks(©, CONST_CAST(char *, string), &len, result, NULL, iterate_memcmp); } @@ -1407,9 +1410,10 @@ CborError cbor_value_text_string_equals(const CborValue *value, const char *stri */ CborError cbor_value_map_find_value(const CborValue *map, const char *string, CborValue *element) { - cbor_assert(cbor_value_is_map(map)); + CborError err; size_t len = strlen(string); - CborError err = cbor_value_enter_container(map, element); + cbor_assert(cbor_value_is_map(map)); + err = cbor_value_enter_container(map, element); if (err) goto error; |