diff options
author | YDBot <ydbot@ydb.tech> | 2025-07-26 00:52:12 +0000 |
---|---|---|
committer | YDBot <ydbot@ydb.tech> | 2025-07-26 00:52:12 +0000 |
commit | c641bf9f3666236b4c2e81273c2c5563c54e4df4 (patch) | |
tree | 1ff5c8e694c9a78ee0e2ad3b0ff5bb5b03818bc7 /contrib/restricted | |
parent | ff32dad4c0a4ac13a90dfb44fdd19a5454cfe13e (diff) | |
parent | 8261eb9dc960f33f6454ac242c06ee8c8bcef5b0 (diff) | |
download | ydb-main.tar.gz |
Diffstat (limited to 'contrib/restricted')
39 files changed, 818 insertions, 737 deletions
diff --git a/contrib/restricted/aws/aws-c-common/.yandex_meta/override.nix b/contrib/restricted/aws/aws-c-common/.yandex_meta/override.nix index 39257f117d8..9025d8985fe 100644 --- a/contrib/restricted/aws/aws-c-common/.yandex_meta/override.nix +++ b/contrib/restricted/aws/aws-c-common/.yandex_meta/override.nix @@ -1,10 +1,10 @@ pkgs: attrs: with pkgs; with attrs; rec { - version = "0.12.3"; + version = "0.12.4"; src = fetchFromGitHub { owner = "awslabs"; repo = "aws-c-common"; rev = "v${version}"; - hash = "sha256-mOn2JZnqWHZ0M6PYkkckCyDjCdp9kKup6CYEew8AgKw="; + hash = "sha256-hKCIPZlLPyH7D3Derk2onyqTzWGUtCx+f2+EKtAKlwA="; }; } diff --git a/contrib/restricted/aws/aws-c-common/THIRD-PARTY-LICENSES.txt b/contrib/restricted/aws/aws-c-common/THIRD-PARTY-LICENSES.txt index 4a3e34675de..876ab4ea789 100644 --- a/contrib/restricted/aws/aws-c-common/THIRD-PARTY-LICENSES.txt +++ b/contrib/restricted/aws/aws-c-common/THIRD-PARTY-LICENSES.txt @@ -34,7 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------ -** cJSON; version 1.7.16 -- https://github.com/DaveGamble/cJSON +** cJSON; version 1.7.18 -- https://github.com/DaveGamble/cJSON Copyright (c) 2009-2017 Dave Gamble and cJSON contributors Permission is hereby granted, free of charge, to any person obtaining a copy @@ -57,7 +57,7 @@ THE SOFTWARE. ------ -** libcbor; version 0.11.0 -- https://github.com/PJK/libcbor +** libcbor; version 0.12.0 -- https://github.com/PJK/libcbor Copyright (c) 2014-2017 Pavel Kalvoda MIT License diff --git a/contrib/restricted/aws/aws-c-common/include/aws/common/byte_order.inl b/contrib/restricted/aws/aws-c-common/include/aws/common/byte_order.inl index 1204be06a1c..d485ac38bc1 100644 --- a/contrib/restricted/aws/aws-c-common/include/aws/common/byte_order.inl +++ b/contrib/restricted/aws/aws-c-common/include/aws/common/byte_order.inl @@ -35,10 +35,8 @@ AWS_STATIC_IMPL uint64_t aws_hton64(uint64_t x) { if (aws_is_big_endian()) { return x; } -#if defined(__x86_64__) && (defined(__GNUC__) || defined(__clang__)) && !defined(CBMC) - uint64_t v; - __asm__("bswap %q0" : "=r"(v) : "0"(x)); - return v; +#if (defined(__GNUC__) || defined(__clang__)) && !defined(CBMC) + return __builtin_bswap64(x); #elif defined(_MSC_VER) return _byteswap_uint64(x); #else diff --git a/contrib/restricted/aws/aws-c-common/include/aws/common/uuid.h b/contrib/restricted/aws/aws-c-common/include/aws/common/uuid.h index e3d9b1adeba..60e12d703f1 100644 --- a/contrib/restricted/aws/aws-c-common/include/aws/common/uuid.h +++ b/contrib/restricted/aws/aws-c-common/include/aws/common/uuid.h @@ -18,12 +18,15 @@ struct aws_uuid { /* 36 bytes for the UUID plus one more for the null terminator. */ enum { AWS_UUID_STR_LEN = 37 }; +/* 32 bytes for the UUID (no dashes) plus one more for the null terminator. */ +enum { AWS_UUID_STR_COMPACT_LEN = 33 }; AWS_EXTERN_C_BEGIN AWS_COMMON_API int aws_uuid_init(struct aws_uuid *uuid); AWS_COMMON_API int aws_uuid_init_from_str(struct aws_uuid *uuid, const struct aws_byte_cursor *uuid_str); AWS_COMMON_API int aws_uuid_to_str(const struct aws_uuid *uuid, struct aws_byte_buf *output); +AWS_COMMON_API int aws_uuid_to_str_compact(const struct aws_uuid *uuid, struct aws_byte_buf *output); AWS_COMMON_API bool aws_uuid_equals(const struct aws_uuid *a, const struct aws_uuid *b); AWS_EXTERN_C_END diff --git a/contrib/restricted/aws/aws-c-common/source/external/cJSON.h b/contrib/restricted/aws/aws-c-common/source/external/cJSON.h index 48cdda9acb0..d5a402f1790 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/cJSON.h +++ b/contrib/restricted/aws/aws-c-common/source/external/cJSON.h @@ -264,7 +264,7 @@ CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse); CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive); /* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from strings. - * The input pointer json cannot point to a read-only address area, such as a string constant, + * The input pointer json cannot point to a read-only address area, such as a string constant, * but should point to a readable and writable address area. */ CJSON_PUBLIC(void) cJSON_Minify(char *json); diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor.c index a8b4bcd7a08..819ff6077c3 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor.c @@ -9,9 +9,8 @@ #include "cbor/internal/builder_callbacks.h" #include "cbor/internal/loaders.h" -#pragma clang diagnostic push -cbor_item_t *cbor_load(cbor_data source, size_t source_size, - struct cbor_load_result *result) { +cbor_item_t* cbor_load(cbor_data source, size_t source_size, + struct cbor_load_result* result) { /* Context stack */ static struct cbor_callbacks callbacks = { .uint8 = &cbor_builder_uint8_callback, @@ -115,8 +114,8 @@ error: return NULL; } -static cbor_item_t *_cbor_copy_int(cbor_item_t *item, bool negative) { - cbor_item_t *res; +static cbor_item_t* _cbor_copy_int(cbor_item_t* item, bool negative) { + cbor_item_t* res = NULL; switch (cbor_int_get_width(item)) { case CBOR_INT_8: res = cbor_build_uint8(cbor_get_uint8(item)); @@ -137,8 +136,7 @@ static cbor_item_t *_cbor_copy_int(cbor_item_t *item, bool negative) { return res; } -static cbor_item_t *_cbor_copy_float_ctrl(cbor_item_t *item) { - // cppcheck-suppress missingReturn +static cbor_item_t* _cbor_copy_float_ctrl(cbor_item_t* item) { switch (cbor_float_get_width(item)) { case CBOR_FLOAT_0: return cbor_build_ctrl(cbor_ctrl_value(item)); @@ -148,11 +146,13 @@ static cbor_item_t *_cbor_copy_float_ctrl(cbor_item_t *item) { return cbor_build_float4(cbor_float_get_float4(item)); case CBOR_FLOAT_64: return cbor_build_float8(cbor_float_get_float8(item)); + default: + _CBOR_UNREACHABLE; + return NULL; } } -cbor_item_t *cbor_copy(cbor_item_t *item) { - // cppcheck-suppress missingReturn +cbor_item_t* cbor_copy(cbor_item_t* item) { switch (cbor_typeof(item)) { case CBOR_TYPE_UINT: return _cbor_copy_int(item, false); @@ -163,13 +163,13 @@ cbor_item_t *cbor_copy(cbor_item_t *item) { return cbor_build_bytestring(cbor_bytestring_handle(item), cbor_bytestring_length(item)); } else { - cbor_item_t *res = cbor_new_indefinite_bytestring(); + cbor_item_t* res = cbor_new_indefinite_bytestring(); if (res == NULL) { return NULL; } for (size_t i = 0; i < cbor_bytestring_chunk_count(item); i++) { - cbor_item_t *chunk_copy = + cbor_item_t* chunk_copy = cbor_copy(cbor_bytestring_chunks_handle(item)[i]); if (chunk_copy == NULL) { cbor_decref(&res); @@ -186,16 +186,16 @@ cbor_item_t *cbor_copy(cbor_item_t *item) { } case CBOR_TYPE_STRING: if (cbor_string_is_definite(item)) { - return cbor_build_stringn((const char *)cbor_string_handle(item), + return cbor_build_stringn((const char*)cbor_string_handle(item), cbor_string_length(item)); } else { - cbor_item_t *res = cbor_new_indefinite_string(); + cbor_item_t* res = cbor_new_indefinite_string(); if (res == NULL) { return NULL; } for (size_t i = 0; i < cbor_string_chunk_count(item); i++) { - cbor_item_t *chunk_copy = + cbor_item_t* chunk_copy = cbor_copy(cbor_string_chunks_handle(item)[i]); if (chunk_copy == NULL) { cbor_decref(&res); @@ -211,7 +211,7 @@ cbor_item_t *cbor_copy(cbor_item_t *item) { return res; } case CBOR_TYPE_ARRAY: { - cbor_item_t *res; + cbor_item_t* res; if (cbor_array_is_definite(item)) { res = cbor_new_definite_array(cbor_array_size(item)); } else { @@ -222,7 +222,7 @@ cbor_item_t *cbor_copy(cbor_item_t *item) { } for (size_t i = 0; i < cbor_array_size(item); i++) { - cbor_item_t *entry_copy = cbor_copy(cbor_move(cbor_array_get(item, i))); + cbor_item_t* entry_copy = cbor_copy(cbor_move(cbor_array_get(item, i))); if (entry_copy == NULL) { cbor_decref(&res); return NULL; @@ -237,7 +237,7 @@ cbor_item_t *cbor_copy(cbor_item_t *item) { return res; } case CBOR_TYPE_MAP: { - cbor_item_t *res; + cbor_item_t* res; if (cbor_map_is_definite(item)) { res = cbor_new_definite_map(cbor_map_size(item)); } else { @@ -247,14 +247,14 @@ cbor_item_t *cbor_copy(cbor_item_t *item) { return NULL; } - struct cbor_pair *it = cbor_map_handle(item); + struct cbor_pair* it = cbor_map_handle(item); for (size_t i = 0; i < cbor_map_size(item); i++) { - cbor_item_t *key_copy = cbor_copy(it[i].key); + cbor_item_t* key_copy = cbor_copy(it[i].key); if (key_copy == NULL) { cbor_decref(&res); return NULL; } - cbor_item_t *value_copy = cbor_copy(it[i].value); + cbor_item_t* value_copy = cbor_copy(it[i].value); if (value_copy == NULL) { cbor_decref(&res); cbor_decref(&key_copy); @@ -273,16 +273,19 @@ cbor_item_t *cbor_copy(cbor_item_t *item) { return res; } case CBOR_TYPE_TAG: { - cbor_item_t *item_copy = cbor_copy(cbor_move(cbor_tag_item(item))); + cbor_item_t* item_copy = cbor_copy(cbor_move(cbor_tag_item(item))); if (item_copy == NULL) { return NULL; } - cbor_item_t *tag = cbor_build_tag(cbor_tag_value(item), item_copy); + cbor_item_t* tag = cbor_build_tag(cbor_tag_value(item), item_copy); cbor_decref(&item_copy); return tag; } case CBOR_TYPE_FLOAT_CTRL: return _cbor_copy_float_ctrl(item); + default: + _CBOR_UNREACHABLE; + return NULL; } } @@ -301,11 +304,11 @@ static int _pow(int b, int ex) { return res; } -static void _cbor_type_marquee(FILE *out, char *label, int indent) { +static void _cbor_type_marquee(FILE* out, char* label, int indent) { fprintf(out, "%*.*s[%s] ", indent, indent, " ", label); } -static void _cbor_nested_describe(cbor_item_t *item, FILE *out, int indent) { +static void _cbor_nested_describe(cbor_item_t* item, FILE* out, int indent) { const int indent_offset = 4; switch (cbor_typeof(item)) { case CBOR_TYPE_UINT: { @@ -329,7 +332,7 @@ static void _cbor_nested_describe(cbor_item_t *item, FILE *out, int indent) { _cbor_nested_describe(cbor_bytestring_chunks_handle(item)[i], out, indent + indent_offset); } else { - const unsigned char *data = cbor_bytestring_handle(item); + const unsigned char* data = cbor_bytestring_handle(item); fprintf(out, "Definite, Length: %zuB, Data:\n", cbor_bytestring_length(item)); fprintf(out, "%*s", indent + indent_offset, " "); @@ -418,7 +421,7 @@ static void _cbor_nested_describe(cbor_item_t *item, FILE *out, int indent) { } } -void cbor_describe(cbor_item_t *item, FILE *out) { +void cbor_describe(cbor_item_t* item, FILE* out) { _cbor_nested_describe(item, out, 0); } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/arrays.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/arrays.c index a23bbe3cd15..174c97e9a61 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/arrays.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/arrays.c @@ -9,21 +9,21 @@ #include <string.h> #include "internal/memory_utils.h" -size_t cbor_array_size(const cbor_item_t *item) { +size_t cbor_array_size(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_array(item)); return item->metadata.array_metadata.end_ptr; } -size_t cbor_array_allocated(const cbor_item_t *item) { +size_t cbor_array_allocated(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_array(item)); return item->metadata.array_metadata.allocated; } -cbor_item_t *cbor_array_get(const cbor_item_t *item, size_t index) { - return cbor_incref(((cbor_item_t **)item->data)[index]); +cbor_item_t* cbor_array_get(const cbor_item_t* item, size_t index) { + return cbor_incref(((cbor_item_t**)item->data)[index]); } -bool cbor_array_set(cbor_item_t *item, size_t index, cbor_item_t *value) { +bool cbor_array_set(cbor_item_t* item, size_t index, cbor_item_t* value) { if (index == item->metadata.array_metadata.end_ptr) { return cbor_array_push(item, value); } else if (index < item->metadata.array_metadata.end_ptr) { @@ -33,19 +33,19 @@ bool cbor_array_set(cbor_item_t *item, size_t index, cbor_item_t *value) { } } -bool cbor_array_replace(cbor_item_t *item, size_t index, cbor_item_t *value) { +bool cbor_array_replace(cbor_item_t* item, size_t index, cbor_item_t* value) { if (index >= item->metadata.array_metadata.end_ptr) return false; /* We cannot use cbor_array_get as that would increase the refcount */ - cbor_intermediate_decref(((cbor_item_t **)item->data)[index]); - ((cbor_item_t **)item->data)[index] = cbor_incref(value); + cbor_intermediate_decref(((cbor_item_t**)item->data)[index]); + ((cbor_item_t**)item->data)[index] = cbor_incref(value); return true; } -bool cbor_array_push(cbor_item_t *array, cbor_item_t *pushee) { +bool cbor_array_push(cbor_item_t* array, cbor_item_t* pushee) { CBOR_ASSERT(cbor_isa_array(array)); - struct _cbor_array_metadata *metadata = - (struct _cbor_array_metadata *)&array->metadata; - cbor_item_t **data = (cbor_item_t **)array->data; + struct _cbor_array_metadata* metadata = + (struct _cbor_array_metadata*)&array->metadata; + cbor_item_t** data = (cbor_item_t**)array->data; if (cbor_array_is_definite(array)) { /* Do not reallocate definite arrays */ if (metadata->end_ptr >= metadata->allocated) { @@ -64,8 +64,8 @@ bool cbor_array_push(cbor_item_t *array, cbor_item_t *pushee) { ? 1 : CBOR_BUFFER_GROWTH * metadata->allocated; - unsigned char *new_data = _cbor_realloc_multiple( - array->data, sizeof(cbor_item_t *), new_allocation); + unsigned char* new_data = _cbor_realloc_multiple( + array->data, sizeof(cbor_item_t*), new_allocation); if (new_data == NULL) { return false; } @@ -73,31 +73,31 @@ bool cbor_array_push(cbor_item_t *array, cbor_item_t *pushee) { array->data = new_data; metadata->allocated = new_allocation; } - ((cbor_item_t **)array->data)[metadata->end_ptr++] = pushee; + ((cbor_item_t**)array->data)[metadata->end_ptr++] = pushee; } cbor_incref(pushee); return true; } -bool cbor_array_is_definite(const cbor_item_t *item) { +bool cbor_array_is_definite(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_array(item)); return item->metadata.array_metadata.type == _CBOR_METADATA_DEFINITE; } -bool cbor_array_is_indefinite(const cbor_item_t *item) { +bool cbor_array_is_indefinite(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_array(item)); return item->metadata.array_metadata.type == _CBOR_METADATA_INDEFINITE; } -cbor_item_t **cbor_array_handle(const cbor_item_t *item) { +cbor_item_t** cbor_array_handle(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_array(item)); - return (cbor_item_t **)item->data; + return (cbor_item_t**)item->data; } -cbor_item_t *cbor_new_definite_array(size_t size) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t)); +cbor_item_t* cbor_new_definite_array(size_t size) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t)); _CBOR_NOTNULL(item); - cbor_item_t **data = _cbor_alloc_multiple(sizeof(cbor_item_t *), size); + cbor_item_t** data = _cbor_alloc_multiple(sizeof(cbor_item_t*), size); _CBOR_DEPENDENT_NOTNULL(item, data); for (size_t i = 0; i < size; i++) { @@ -110,13 +110,13 @@ cbor_item_t *cbor_new_definite_array(size_t size) { .metadata = {.array_metadata = {.type = _CBOR_METADATA_DEFINITE, .allocated = size, .end_ptr = 0}}, - .data = (unsigned char *)data}; + .data = (unsigned char*)data}; return item; } -cbor_item_t *cbor_new_indefinite_array(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t)); +cbor_item_t* cbor_new_indefinite_array(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t)); _CBOR_NOTNULL(item); *item = (cbor_item_t){ diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/bytestrings.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/bytestrings.c index 528937179ae..f8290a56328 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/bytestrings.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/bytestrings.c @@ -9,27 +9,27 @@ #include <string.h> #include "internal/memory_utils.h" -size_t cbor_bytestring_length(const cbor_item_t *item) { +size_t cbor_bytestring_length(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_bytestring(item)); return item->metadata.bytestring_metadata.length; } -unsigned char *cbor_bytestring_handle(const cbor_item_t *item) { +unsigned char* cbor_bytestring_handle(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_bytestring(item)); return item->data; } -bool cbor_bytestring_is_definite(const cbor_item_t *item) { +bool cbor_bytestring_is_definite(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_bytestring(item)); return item->metadata.bytestring_metadata.type == _CBOR_METADATA_DEFINITE; } -bool cbor_bytestring_is_indefinite(const cbor_item_t *item) { +bool cbor_bytestring_is_indefinite(const cbor_item_t* item) { return !cbor_bytestring_is_definite(item); } -cbor_item_t *cbor_new_definite_bytestring(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t)); +cbor_item_t* cbor_new_definite_bytestring(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t)); _CBOR_NOTNULL(item); *item = (cbor_item_t){ .refcount = 1, @@ -39,8 +39,8 @@ cbor_item_t *cbor_new_definite_bytestring(void) { return item; } -cbor_item_t *cbor_new_indefinite_bytestring(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t)); +cbor_item_t* cbor_new_indefinite_bytestring(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t)); _CBOR_NOTNULL(item); *item = (cbor_item_t){ .refcount = 1, @@ -49,7 +49,7 @@ cbor_item_t *cbor_new_indefinite_bytestring(void) { .length = 0}}, .data = _cbor_malloc(sizeof(struct cbor_indefinite_string_data))}; _CBOR_DEPENDENT_NOTNULL(item, item->data); - *((struct cbor_indefinite_string_data *)item->data) = + *((struct cbor_indefinite_string_data*)item->data) = (struct cbor_indefinite_string_data){ .chunk_count = 0, .chunk_capacity = 0, @@ -58,17 +58,17 @@ cbor_item_t *cbor_new_indefinite_bytestring(void) { return item; } -cbor_item_t *cbor_build_bytestring(cbor_data handle, size_t length) { - cbor_item_t *item = cbor_new_definite_bytestring(); +cbor_item_t* cbor_build_bytestring(cbor_data handle, size_t length) { + cbor_item_t* item = cbor_new_definite_bytestring(); _CBOR_NOTNULL(item); - void *content = _cbor_malloc(length); + void* content = _cbor_malloc(length); _CBOR_DEPENDENT_NOTNULL(item, content); memcpy(content, handle, length); cbor_bytestring_set_handle(item, content, length); return item; } -void cbor_bytestring_set_handle(cbor_item_t *item, +void cbor_bytestring_set_handle(cbor_item_t* item, cbor_mutable_data CBOR_RESTRICT_POINTER data, size_t length) { CBOR_ASSERT(cbor_isa_bytestring(item)); @@ -77,25 +77,25 @@ void cbor_bytestring_set_handle(cbor_item_t *item, item->metadata.bytestring_metadata.length = length; } -cbor_item_t **cbor_bytestring_chunks_handle(const cbor_item_t *item) { +cbor_item_t** cbor_bytestring_chunks_handle(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_bytestring(item)); CBOR_ASSERT(cbor_bytestring_is_indefinite(item)); - return ((struct cbor_indefinite_string_data *)item->data)->chunks; + return ((struct cbor_indefinite_string_data*)item->data)->chunks; } -size_t cbor_bytestring_chunk_count(const cbor_item_t *item) { +size_t cbor_bytestring_chunk_count(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_bytestring(item)); CBOR_ASSERT(cbor_bytestring_is_indefinite(item)); - return ((struct cbor_indefinite_string_data *)item->data)->chunk_count; + return ((struct cbor_indefinite_string_data*)item->data)->chunk_count; } -bool cbor_bytestring_add_chunk(cbor_item_t *item, cbor_item_t *chunk) { +bool cbor_bytestring_add_chunk(cbor_item_t* item, cbor_item_t* chunk) { CBOR_ASSERT(cbor_isa_bytestring(item)); CBOR_ASSERT(cbor_bytestring_is_indefinite(item)); CBOR_ASSERT(cbor_isa_bytestring(chunk)); CBOR_ASSERT(cbor_bytestring_is_definite(chunk)); - struct cbor_indefinite_string_data *data = - (struct cbor_indefinite_string_data *)item->data; + struct cbor_indefinite_string_data* data = + (struct cbor_indefinite_string_data*)item->data; if (data->chunk_count == data->chunk_capacity) { if (!_cbor_safe_to_multiply(CBOR_BUFFER_GROWTH, data->chunk_capacity)) { return false; @@ -105,8 +105,8 @@ bool cbor_bytestring_add_chunk(cbor_item_t *item, cbor_item_t *chunk) { data->chunk_capacity == 0 ? 1 : CBOR_BUFFER_GROWTH * (data->chunk_capacity); - cbor_item_t **new_chunks_data = _cbor_realloc_multiple( - data->chunks, sizeof(cbor_item_t *), new_chunk_capacity); + cbor_item_t** new_chunks_data = _cbor_realloc_multiple( + data->chunks, sizeof(cbor_item_t*), new_chunk_capacity); if (new_chunks_data == NULL) { return false; diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/bytestrings.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/bytestrings.h index cacd1adf95f..59cae2add7f 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/bytestrings.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/bytestrings.h @@ -29,7 +29,7 @@ extern "C" { * @return length of the binary data. Zero if no chunk has been attached yet */ _CBOR_NODISCARD -CBOR_EXPORT size_t cbor_bytestring_length(const cbor_item_t *item); +CBOR_EXPORT size_t cbor_bytestring_length(const cbor_item_t* item); /** Is the byte string definite? * @@ -37,7 +37,7 @@ CBOR_EXPORT size_t cbor_bytestring_length(const cbor_item_t *item); * @return Is the byte string definite? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_bytestring_is_definite(const cbor_item_t *item); +CBOR_EXPORT bool cbor_bytestring_is_definite(const cbor_item_t* item); /** Is the byte string indefinite? * @@ -45,7 +45,7 @@ CBOR_EXPORT bool cbor_bytestring_is_definite(const cbor_item_t *item); * @return Is the byte string indefinite? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_bytestring_is_indefinite(const cbor_item_t *item); +CBOR_EXPORT bool cbor_bytestring_is_indefinite(const cbor_item_t* item); /** Get the handle to the binary data * @@ -58,7 +58,7 @@ CBOR_EXPORT bool cbor_bytestring_is_indefinite(const cbor_item_t *item); * yet. */ _CBOR_NODISCARD -CBOR_EXPORT cbor_mutable_data cbor_bytestring_handle(const cbor_item_t *item); +CBOR_EXPORT cbor_mutable_data cbor_bytestring_handle(const cbor_item_t* item); /** Set the handle to the binary data * @@ -69,7 +69,7 @@ CBOR_EXPORT cbor_mutable_data cbor_bytestring_handle(const cbor_item_t *item); * @param length Length of the data block */ CBOR_EXPORT void cbor_bytestring_set_handle( - cbor_item_t *item, cbor_mutable_data CBOR_RESTRICT_POINTER data, + cbor_item_t* item, cbor_mutable_data CBOR_RESTRICT_POINTER data, size_t length); /** Get the handle to the array of chunks @@ -81,8 +81,8 @@ CBOR_EXPORT void cbor_bytestring_set_handle( * @return array of #cbor_bytestring_chunk_count definite bytestrings */ _CBOR_NODISCARD -CBOR_EXPORT cbor_item_t **cbor_bytestring_chunks_handle( - const cbor_item_t *item); +CBOR_EXPORT cbor_item_t** cbor_bytestring_chunks_handle( + const cbor_item_t* item); /** Get the number of chunks this string consist of * @@ -90,7 +90,7 @@ CBOR_EXPORT cbor_item_t **cbor_bytestring_chunks_handle( * @return The chunk count. 0 for freshly created items. */ _CBOR_NODISCARD -CBOR_EXPORT size_t cbor_bytestring_chunk_count(const cbor_item_t *item); +CBOR_EXPORT size_t cbor_bytestring_chunk_count(const cbor_item_t* item); /** Appends a chunk to the bytestring * @@ -105,8 +105,8 @@ CBOR_EXPORT size_t cbor_bytestring_chunk_count(const cbor_item_t *item); * of `chunk` is not increased and the `item` is left intact. */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_bytestring_add_chunk(cbor_item_t *item, - cbor_item_t *chunk); +CBOR_EXPORT bool cbor_bytestring_add_chunk(cbor_item_t* item, + cbor_item_t* chunk); /** Creates a new definite byte string * @@ -117,7 +117,7 @@ CBOR_EXPORT bool cbor_bytestring_add_chunk(cbor_item_t *item, * @return `NULL` if memory allocation fails */ _CBOR_NODISCARD -CBOR_EXPORT cbor_item_t *cbor_new_definite_bytestring(void); +CBOR_EXPORT cbor_item_t* cbor_new_definite_bytestring(void); /** Creates a new indefinite byte string * @@ -128,7 +128,7 @@ CBOR_EXPORT cbor_item_t *cbor_new_definite_bytestring(void); * @return `NULL` if memory allocation fails */ _CBOR_NODISCARD -CBOR_EXPORT cbor_item_t *cbor_new_indefinite_bytestring(void); +CBOR_EXPORT cbor_item_t* cbor_new_indefinite_bytestring(void); /** Creates a new byte string and initializes it * @@ -141,7 +141,7 @@ CBOR_EXPORT cbor_item_t *cbor_new_indefinite_bytestring(void); * @return `NULL` if memory allocation fails */ _CBOR_NODISCARD -CBOR_EXPORT cbor_item_t *cbor_build_bytestring(cbor_data handle, size_t length); +CBOR_EXPORT cbor_item_t* cbor_build_bytestring(cbor_data handle, size_t length); #ifdef __cplusplus } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/callbacks.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/callbacks.c index bdf3f79eee6..2b58edaa0bc 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/callbacks.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/callbacks.c @@ -7,72 +7,72 @@ #include "callbacks.h" -void cbor_null_uint8_callback(void *_CBOR_UNUSED(_ctx), - uint8_t _CBOR_UNUSED(_val)) {} +void cbor_null_uint8_callback(void* _ctx _CBOR_UNUSED, + uint8_t _CBOR_UNUSED _val) {} -void cbor_null_uint16_callback(void *_CBOR_UNUSED(_ctx), - uint16_t _CBOR_UNUSED(_val)) {} +void cbor_null_uint16_callback(void* _ctx _CBOR_UNUSED, + uint16_t _CBOR_UNUSED _val) {} -void cbor_null_uint32_callback(void *_CBOR_UNUSED(_ctx), - uint32_t _CBOR_UNUSED(_val)) {} +void cbor_null_uint32_callback(void* _ctx _CBOR_UNUSED, + uint32_t _CBOR_UNUSED _val) {} -void cbor_null_uint64_callback(void *_CBOR_UNUSED(_ctx), - uint64_t _CBOR_UNUSED(_val)) {} +void cbor_null_uint64_callback(void* _ctx _CBOR_UNUSED, + uint64_t _CBOR_UNUSED _val) {} -void cbor_null_negint8_callback(void *_CBOR_UNUSED(_ctx), - uint8_t _CBOR_UNUSED(_val)) {} +void cbor_null_negint8_callback(void* _ctx _CBOR_UNUSED, + uint8_t _CBOR_UNUSED _val) {} -void cbor_null_negint16_callback(void *_CBOR_UNUSED(_ctx), - uint16_t _CBOR_UNUSED(_val)) {} +void cbor_null_negint16_callback(void* _ctx _CBOR_UNUSED, + uint16_t _CBOR_UNUSED _val) {} -void cbor_null_negint32_callback(void *_CBOR_UNUSED(_ctx), - uint32_t _CBOR_UNUSED(_val)) {} +void cbor_null_negint32_callback(void* _ctx _CBOR_UNUSED, + uint32_t _CBOR_UNUSED _val) {} -void cbor_null_negint64_callback(void *_CBOR_UNUSED(_ctx), - uint64_t _CBOR_UNUSED(_val)) {} +void cbor_null_negint64_callback(void* _ctx _CBOR_UNUSED, + uint64_t _CBOR_UNUSED _val) {} -void cbor_null_string_callback(void *_CBOR_UNUSED(_ctx), - cbor_data _CBOR_UNUSED(_val), - uint64_t _CBOR_UNUSED(_val2)) {} +void cbor_null_string_callback(void* _ctx _CBOR_UNUSED, + cbor_data _CBOR_UNUSED _val, + uint64_t _CBOR_UNUSED _val2) {} -void cbor_null_string_start_callback(void *_CBOR_UNUSED(_ctx)) {} +void cbor_null_string_start_callback(void* _ctx _CBOR_UNUSED) {} -void cbor_null_byte_string_callback(void *_CBOR_UNUSED(_ctx), - cbor_data _CBOR_UNUSED(_val), - uint64_t _CBOR_UNUSED(_val2)) {} +void cbor_null_byte_string_callback(void* _ctx _CBOR_UNUSED, + cbor_data _CBOR_UNUSED _val, + uint64_t _CBOR_UNUSED _val2) {} -void cbor_null_byte_string_start_callback(void *_CBOR_UNUSED(_ctx)) {} +void cbor_null_byte_string_start_callback(void* _ctx _CBOR_UNUSED) {} -void cbor_null_array_start_callback(void *_CBOR_UNUSED(_ctx), - uint64_t _CBOR_UNUSED(_val)) {} +void cbor_null_array_start_callback(void* _ctx _CBOR_UNUSED, + uint64_t _CBOR_UNUSED _val) {} -void cbor_null_indef_array_start_callback(void *_CBOR_UNUSED(_ctx)) {} +void cbor_null_indef_array_start_callback(void* _ctx _CBOR_UNUSED) {} -void cbor_null_map_start_callback(void *_CBOR_UNUSED(_ctx), - uint64_t _CBOR_UNUSED(_val)) {} +void cbor_null_map_start_callback(void* _ctx _CBOR_UNUSED, + uint64_t _CBOR_UNUSED _val) {} -void cbor_null_indef_map_start_callback(void *_CBOR_UNUSED(_ctx)) {} +void cbor_null_indef_map_start_callback(void* _ctx _CBOR_UNUSED) {} -void cbor_null_tag_callback(void *_CBOR_UNUSED(_ctx), - uint64_t _CBOR_UNUSED(_val)) {} +void cbor_null_tag_callback(void* _ctx _CBOR_UNUSED, + uint64_t _CBOR_UNUSED _val) {} -void cbor_null_float2_callback(void *_CBOR_UNUSED(_ctx), - float _CBOR_UNUSED(_val)) {} +void cbor_null_float2_callback(void* _ctx _CBOR_UNUSED, + float _CBOR_UNUSED _val) {} -void cbor_null_float4_callback(void *_CBOR_UNUSED(_ctx), - float _CBOR_UNUSED(_val)) {} +void cbor_null_float4_callback(void* _ctx _CBOR_UNUSED, + float _CBOR_UNUSED _val) {} -void cbor_null_float8_callback(void *_CBOR_UNUSED(_ctx), - double _CBOR_UNUSED(_val)) {} +void cbor_null_float8_callback(void* _ctx _CBOR_UNUSED, + double _CBOR_UNUSED _val) {} -void cbor_null_null_callback(void *_CBOR_UNUSED(_ctx)) {} +void cbor_null_null_callback(void* _ctx _CBOR_UNUSED) {} -void cbor_null_undefined_callback(void *_CBOR_UNUSED(_ctx)) {} +void cbor_null_undefined_callback(void* _ctx _CBOR_UNUSED) {} -void cbor_null_boolean_callback(void *_CBOR_UNUSED(_ctx), - bool _CBOR_UNUSED(_val)) {} +void cbor_null_boolean_callback(void* _ctx _CBOR_UNUSED, + bool _CBOR_UNUSED _val) {} -void cbor_null_indef_break_callback(void *_CBOR_UNUSED(_ctx)) {} +void cbor_null_indef_break_callback(void* _ctx _CBOR_UNUSED) {} CBOR_EXPORT const struct cbor_callbacks cbor_empty_callbacks = { /* Type 0 - Unsigned integers */ diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/callbacks.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/callbacks.h index c7ae20568dc..f5fab43bc71 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/callbacks.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/callbacks.h @@ -18,34 +18,34 @@ extern "C" { #endif /** Callback prototype */ -typedef void (*cbor_int8_callback)(void *, uint8_t); +typedef void (*cbor_int8_callback)(void*, uint8_t); /** Callback prototype */ -typedef void (*cbor_int16_callback)(void *, uint16_t); +typedef void (*cbor_int16_callback)(void*, uint16_t); /** Callback prototype */ -typedef void (*cbor_int32_callback)(void *, uint32_t); +typedef void (*cbor_int32_callback)(void*, uint32_t); /** Callback prototype */ -typedef void (*cbor_int64_callback)(void *, uint64_t); +typedef void (*cbor_int64_callback)(void*, uint64_t); /** Callback prototype */ -typedef void (*cbor_simple_callback)(void *); +typedef void (*cbor_simple_callback)(void*); /** Callback prototype */ -typedef void (*cbor_string_callback)(void *, cbor_data, uint64_t); +typedef void (*cbor_string_callback)(void*, cbor_data, uint64_t); /** Callback prototype */ -typedef void (*cbor_collection_callback)(void *, uint64_t); +typedef void (*cbor_collection_callback)(void*, uint64_t); /** Callback prototype */ -typedef void (*cbor_float_callback)(void *, float); +typedef void (*cbor_float_callback)(void*, float); /** Callback prototype */ -typedef void (*cbor_double_callback)(void *, double); +typedef void (*cbor_double_callback)(void*, double); /** Callback prototype */ -typedef void (*cbor_bool_callback)(void *, bool); +typedef void (*cbor_bool_callback)(void*, bool); /** Callback bundle -- passed to the decoder */ struct cbor_callbacks { @@ -108,76 +108,76 @@ struct cbor_callbacks { }; /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_uint8_callback(void *, uint8_t); +CBOR_EXPORT void cbor_null_uint8_callback(void*, uint8_t); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_uint16_callback(void *, uint16_t); +CBOR_EXPORT void cbor_null_uint16_callback(void*, uint16_t); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_uint32_callback(void *, uint32_t); +CBOR_EXPORT void cbor_null_uint32_callback(void*, uint32_t); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_uint64_callback(void *, uint64_t); +CBOR_EXPORT void cbor_null_uint64_callback(void*, uint64_t); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_negint8_callback(void *, uint8_t); +CBOR_EXPORT void cbor_null_negint8_callback(void*, uint8_t); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_negint16_callback(void *, uint16_t); +CBOR_EXPORT void cbor_null_negint16_callback(void*, uint16_t); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_negint32_callback(void *, uint32_t); +CBOR_EXPORT void cbor_null_negint32_callback(void*, uint32_t); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_negint64_callback(void *, uint64_t); +CBOR_EXPORT void cbor_null_negint64_callback(void*, uint64_t); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_string_callback(void *, cbor_data, uint64_t); +CBOR_EXPORT void cbor_null_string_callback(void*, cbor_data, uint64_t); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_string_start_callback(void *); +CBOR_EXPORT void cbor_null_string_start_callback(void*); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_byte_string_callback(void *, cbor_data, uint64_t); +CBOR_EXPORT void cbor_null_byte_string_callback(void*, cbor_data, uint64_t); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_byte_string_start_callback(void *); +CBOR_EXPORT void cbor_null_byte_string_start_callback(void*); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_array_start_callback(void *, uint64_t); +CBOR_EXPORT void cbor_null_array_start_callback(void*, uint64_t); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_indef_array_start_callback(void *); +CBOR_EXPORT void cbor_null_indef_array_start_callback(void*); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_map_start_callback(void *, uint64_t); +CBOR_EXPORT void cbor_null_map_start_callback(void*, uint64_t); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_indef_map_start_callback(void *); +CBOR_EXPORT void cbor_null_indef_map_start_callback(void*); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_tag_callback(void *, uint64_t); +CBOR_EXPORT void cbor_null_tag_callback(void*, uint64_t); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_float2_callback(void *, float); +CBOR_EXPORT void cbor_null_float2_callback(void*, float); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_float4_callback(void *, float); +CBOR_EXPORT void cbor_null_float4_callback(void*, float); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_float8_callback(void *, double); +CBOR_EXPORT void cbor_null_float8_callback(void*, double); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_null_callback(void *); +CBOR_EXPORT void cbor_null_null_callback(void*); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_undefined_callback(void *); +CBOR_EXPORT void cbor_null_undefined_callback(void*); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_boolean_callback(void *, bool); +CBOR_EXPORT void cbor_null_boolean_callback(void*, bool); /** Dummy callback implementation - does nothing */ -CBOR_EXPORT void cbor_null_indef_break_callback(void *); +CBOR_EXPORT void cbor_null_indef_break_callback(void*); /** Dummy callback bundle - does nothing */ CBOR_EXPORT extern const struct cbor_callbacks cbor_empty_callbacks; diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/common.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/common.c index efbd37ed79d..704dd0c3205 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/common.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/common.c @@ -19,69 +19,69 @@ bool _cbor_enable_assert = true; #endif -bool cbor_isa_uint(const cbor_item_t *item) { +bool cbor_isa_uint(const cbor_item_t* item) { return item->type == CBOR_TYPE_UINT; } -bool cbor_isa_negint(const cbor_item_t *item) { +bool cbor_isa_negint(const cbor_item_t* item) { return item->type == CBOR_TYPE_NEGINT; } -bool cbor_isa_bytestring(const cbor_item_t *item) { +bool cbor_isa_bytestring(const cbor_item_t* item) { return item->type == CBOR_TYPE_BYTESTRING; } -bool cbor_isa_string(const cbor_item_t *item) { +bool cbor_isa_string(const cbor_item_t* item) { return item->type == CBOR_TYPE_STRING; } -bool cbor_isa_array(const cbor_item_t *item) { +bool cbor_isa_array(const cbor_item_t* item) { return item->type == CBOR_TYPE_ARRAY; } -bool cbor_isa_map(const cbor_item_t *item) { +bool cbor_isa_map(const cbor_item_t* item) { return item->type == CBOR_TYPE_MAP; } -bool cbor_isa_tag(const cbor_item_t *item) { +bool cbor_isa_tag(const cbor_item_t* item) { return item->type == CBOR_TYPE_TAG; } -bool cbor_isa_float_ctrl(const cbor_item_t *item) { +bool cbor_isa_float_ctrl(const cbor_item_t* item) { return item->type == CBOR_TYPE_FLOAT_CTRL; } -cbor_type cbor_typeof(const cbor_item_t *item) { return item->type; } +cbor_type cbor_typeof(const cbor_item_t* item) { return item->type; } -bool cbor_is_int(const cbor_item_t *item) { +bool cbor_is_int(const cbor_item_t* item) { return cbor_isa_uint(item) || cbor_isa_negint(item); } -bool cbor_is_bool(const cbor_item_t *item) { +bool cbor_is_bool(const cbor_item_t* item) { return cbor_isa_float_ctrl(item) && (cbor_ctrl_value(item) == CBOR_CTRL_FALSE || cbor_ctrl_value(item) == CBOR_CTRL_TRUE); } -bool cbor_is_null(const cbor_item_t *item) { +bool cbor_is_null(const cbor_item_t* item) { return cbor_isa_float_ctrl(item) && cbor_ctrl_value(item) == CBOR_CTRL_NULL; } -bool cbor_is_undef(const cbor_item_t *item) { +bool cbor_is_undef(const cbor_item_t* item) { return cbor_isa_float_ctrl(item) && cbor_ctrl_value(item) == CBOR_CTRL_UNDEF; } -bool cbor_is_float(const cbor_item_t *item) { +bool cbor_is_float(const cbor_item_t* item) { return cbor_isa_float_ctrl(item) && !cbor_float_ctrl_is_ctrl(item); } -cbor_item_t *cbor_incref(cbor_item_t *item) { +cbor_item_t* cbor_incref(cbor_item_t* item) { item->refcount++; return item; } -void cbor_decref(cbor_item_t **item_ref) { - cbor_item_t *item = *item_ref; +void cbor_decref(cbor_item_t** item_ref) { + cbor_item_t* item = *item_ref; CBOR_ASSERT(item->refcount > 0); if (--item->refcount == 0) { switch (item->type) { @@ -95,11 +95,10 @@ void cbor_decref(cbor_item_t **item_ref) { _cbor_free(item->data); } else { /* We need to decref all chunks */ - cbor_item_t **handle = cbor_bytestring_chunks_handle(item); + cbor_item_t** handle = cbor_bytestring_chunks_handle(item); for (size_t i = 0; i < cbor_bytestring_chunk_count(item); i++) cbor_decref(&handle[i]); - _cbor_free( - ((struct cbor_indefinite_string_data *)item->data)->chunks); + _cbor_free(((struct cbor_indefinite_string_data*)item->data)->chunks); _cbor_free(item->data); } break; @@ -109,18 +108,17 @@ void cbor_decref(cbor_item_t **item_ref) { _cbor_free(item->data); } else { /* We need to decref all chunks */ - cbor_item_t **handle = cbor_string_chunks_handle(item); + cbor_item_t** handle = cbor_string_chunks_handle(item); for (size_t i = 0; i < cbor_string_chunk_count(item); i++) cbor_decref(&handle[i]); - _cbor_free( - ((struct cbor_indefinite_string_data *)item->data)->chunks); + _cbor_free(((struct cbor_indefinite_string_data*)item->data)->chunks); _cbor_free(item->data); } break; } case CBOR_TYPE_ARRAY: { /* Get all items and decref them */ - cbor_item_t **handle = cbor_array_handle(item); + cbor_item_t** handle = cbor_array_handle(item); size_t size = cbor_array_size(item); for (size_t i = 0; i < size; i++) if (handle[i] != NULL) cbor_decref(&handle[i]); @@ -128,7 +126,7 @@ void cbor_decref(cbor_item_t **item_ref) { break; } case CBOR_TYPE_MAP: { - struct cbor_pair *handle = cbor_map_handle(item); + struct cbor_pair* handle = cbor_map_handle(item); for (size_t i = 0; i < item->metadata.map_metadata.end_ptr; i++, handle++) { cbor_decref(&handle->key); @@ -153,11 +151,11 @@ void cbor_decref(cbor_item_t **item_ref) { } } -void cbor_intermediate_decref(cbor_item_t *item) { cbor_decref(&item); } +void cbor_intermediate_decref(cbor_item_t* item) { cbor_decref(&item); } -size_t cbor_refcount(const cbor_item_t *item) { return item->refcount; } +size_t cbor_refcount(const cbor_item_t* item) { return item->refcount; } -cbor_item_t *cbor_move(cbor_item_t *item) { +cbor_item_t* cbor_move(cbor_item_t* item) { item->refcount--; return item; } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/common.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/common.h index 1d0b426cff4..89968db9544 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/common.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/common.h @@ -81,21 +81,27 @@ extern bool _cbor_enable_assert; #define _CBOR_TO_STR(x) _CBOR_TO_STR_(x) /* enables proper double expansion */ #ifdef __GNUC__ -#define _CBOR_UNUSED(x) __attribute__((__unused__)) x +#define _CBOR_UNUSED __attribute__((__unused__)) // TODO(https://github.com/PJK/libcbor/issues/247): Prefer [[nodiscard]] if // available #define _CBOR_NODISCARD __attribute__((warn_unused_result)) #elif defined(_MSC_VER) -#define _CBOR_UNUSED(x) __pragma(warning(suppress : 4100 4101)) x +#define _CBOR_UNUSED __pragma(warning(suppress : 4100 4101)) #define _CBOR_NODISCARD #else -#define _CBOR_UNUSED(x) x +#define _CBOR_UNUSED #define _CBOR_NODISCARD #endif -typedef void *(*_cbor_malloc_t)(size_t); -typedef void *(*_cbor_realloc_t)(void *, size_t); -typedef void (*_cbor_free_t)(void *); +#ifdef CBOR_HAS_BUILTIN_UNREACHABLE +#define _CBOR_UNREACHABLE __builtin_unreachable() +#else +#define _CBOR_UNREACHABLE +#endif + +typedef void* (*_cbor_malloc_t)(size_t); +typedef void* (*_cbor_realloc_t)(void*, size_t); +typedef void (*_cbor_free_t)(void*); CBOR_EXPORT extern _cbor_malloc_t _cbor_malloc; CBOR_EXPORT extern _cbor_realloc_t _cbor_realloc; @@ -155,7 +161,7 @@ CBOR_EXPORT void cbor_set_allocs(_cbor_malloc_t custom_malloc, */ _CBOR_NODISCARD CBOR_EXPORT cbor_type cbor_typeof( - const cbor_item_t *item); /* Will be inlined iff link-time opt is enabled */ + const cbor_item_t* item); /* Will be inlined iff link-time opt is enabled */ /* Standard CBOR Major item types */ @@ -164,56 +170,56 @@ CBOR_EXPORT cbor_type cbor_typeof( * @return Is the item an #CBOR_TYPE_UINT? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_isa_uint(const cbor_item_t *item); +CBOR_EXPORT bool cbor_isa_uint(const cbor_item_t* item); /** Does the item have the appropriate major type? * @param item the item * @return Is the item a #CBOR_TYPE_NEGINT? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_isa_negint(const cbor_item_t *item); +CBOR_EXPORT bool cbor_isa_negint(const cbor_item_t* item); /** Does the item have the appropriate major type? * @param item the item * @return Is the item a #CBOR_TYPE_BYTESTRING? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_isa_bytestring(const cbor_item_t *item); +CBOR_EXPORT bool cbor_isa_bytestring(const cbor_item_t* item); /** Does the item have the appropriate major type? * @param item the item * @return Is the item a #CBOR_TYPE_STRING? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_isa_string(const cbor_item_t *item); +CBOR_EXPORT bool cbor_isa_string(const cbor_item_t* item); /** Does the item have the appropriate major type? * @param item the item * @return Is the item an #CBOR_TYPE_ARRAY? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_isa_array(const cbor_item_t *item); +CBOR_EXPORT bool cbor_isa_array(const cbor_item_t* item); /** Does the item have the appropriate major type? * @param item the item * @return Is the item a #CBOR_TYPE_MAP? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_isa_map(const cbor_item_t *item); +CBOR_EXPORT bool cbor_isa_map(const cbor_item_t* item); /** Does the item have the appropriate major type? * @param item the item * @return Is the item a #CBOR_TYPE_TAG? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_isa_tag(const cbor_item_t *item); +CBOR_EXPORT bool cbor_isa_tag(const cbor_item_t* item); /** Does the item have the appropriate major type? * @param item the item * @return Is the item a #CBOR_TYPE_FLOAT_CTRL? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_isa_float_ctrl(const cbor_item_t *item); +CBOR_EXPORT bool cbor_isa_float_ctrl(const cbor_item_t* item); /* Practical types with respect to their semantics (but not tag values) */ @@ -222,21 +228,21 @@ CBOR_EXPORT bool cbor_isa_float_ctrl(const cbor_item_t *item); * @return Is the item an integer, either positive or negative? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_is_int(const cbor_item_t *item); +CBOR_EXPORT bool cbor_is_int(const cbor_item_t* item); /** Is the item an a floating point number? * @param item the item * @return Is the item a floating point number? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_is_float(const cbor_item_t *item); +CBOR_EXPORT bool cbor_is_float(const cbor_item_t* item); /** Is the item an a boolean? * @param item the item * @return Is the item a boolean? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_is_bool(const cbor_item_t *item); +CBOR_EXPORT bool cbor_is_bool(const cbor_item_t* item); /** Does this item represent `null` * @@ -249,7 +255,7 @@ CBOR_EXPORT bool cbor_is_bool(const cbor_item_t *item); * @return Is the item (CBOR logical) null? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_is_null(const cbor_item_t *item); +CBOR_EXPORT bool cbor_is_null(const cbor_item_t* item); /** Does this item represent `undefined` * @@ -262,7 +268,7 @@ CBOR_EXPORT bool cbor_is_null(const cbor_item_t *item); * @return Is the item (CBOR logical) undefined? */ _CBOR_NODISCARD -CBOR_EXPORT bool cbor_is_undef(const cbor_item_t *item); +CBOR_EXPORT bool cbor_is_undef(const cbor_item_t* item); /* * ============================================================================ @@ -280,7 +286,7 @@ CBOR_EXPORT bool cbor_is_undef(const cbor_item_t *item); * @param item Reference to an item * @return The input \p item */ -CBOR_EXPORT cbor_item_t *cbor_incref(cbor_item_t *item); +CBOR_EXPORT cbor_item_t* cbor_incref(cbor_item_t* item); /** Decreases the item's reference count by one, deallocating the item if needed * @@ -289,7 +295,7 @@ CBOR_EXPORT cbor_item_t *cbor_incref(cbor_item_t *item); * * @param item Reference to an item. Will be set to `NULL` if deallocated */ -CBOR_EXPORT void cbor_decref(cbor_item_t **item); +CBOR_EXPORT void cbor_decref(cbor_item_t** item); /** Decreases the item's reference count by one, deallocating the item if needed * @@ -298,7 +304,7 @@ CBOR_EXPORT void cbor_decref(cbor_item_t **item); * * @param item Reference to an item */ -CBOR_EXPORT void cbor_intermediate_decref(cbor_item_t *item); +CBOR_EXPORT void cbor_intermediate_decref(cbor_item_t* item); /** Get the item's reference count * @@ -312,7 +318,7 @@ CBOR_EXPORT void cbor_intermediate_decref(cbor_item_t *item); * @return the reference count */ _CBOR_NODISCARD -CBOR_EXPORT size_t cbor_refcount(const cbor_item_t *item); +CBOR_EXPORT size_t cbor_refcount(const cbor_item_t* item); /** Provides CPP-like move construct * @@ -330,7 +336,7 @@ CBOR_EXPORT size_t cbor_refcount(const cbor_item_t *item); * @return the item with reference count decreased by one */ _CBOR_NODISCARD -CBOR_EXPORT cbor_item_t *cbor_move(cbor_item_t *item); +CBOR_EXPORT cbor_item_t* cbor_move(cbor_item_t* item); #ifdef __cplusplus } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/configuration.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/configuration.h index 83fe90bd356..b7278293329 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/configuration.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/configuration.h @@ -9,7 +9,7 @@ #define LIBCBOR_CONFIGURATION_H #define CBOR_MAJOR_VERSION 0 -#define CBOR_MINOR_VERSION 11 +#define CBOR_MINOR_VERSION 12 #define CBOR_PATCH_VERSION 0 #define CBOR_BUFFER_GROWTH 2 diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/encoding.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/encoding.c index 9d931d17570..76be4de9da3 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/encoding.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/encoding.c @@ -6,64 +6,67 @@ */ #include "encoding.h" + +#include <math.h> + #include "internal/encoders.h" -size_t cbor_encode_uint8(uint8_t value, unsigned char *buffer, +size_t cbor_encode_uint8(uint8_t value, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint8(value, buffer, buffer_size, 0x00); } -size_t cbor_encode_uint16(uint16_t value, unsigned char *buffer, +size_t cbor_encode_uint16(uint16_t value, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint16(value, buffer, buffer_size, 0x00); } -size_t cbor_encode_uint32(uint32_t value, unsigned char *buffer, +size_t cbor_encode_uint32(uint32_t value, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint32(value, buffer, buffer_size, 0x00); } -size_t cbor_encode_uint64(uint64_t value, unsigned char *buffer, +size_t cbor_encode_uint64(uint64_t value, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint64(value, buffer, buffer_size, 0x00); } -size_t cbor_encode_uint(uint64_t value, unsigned char *buffer, +size_t cbor_encode_uint(uint64_t value, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint(value, buffer, buffer_size, 0x00); } -size_t cbor_encode_negint8(uint8_t value, unsigned char *buffer, +size_t cbor_encode_negint8(uint8_t value, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint8(value, buffer, buffer_size, 0x20); } -size_t cbor_encode_negint16(uint16_t value, unsigned char *buffer, +size_t cbor_encode_negint16(uint16_t value, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint16(value, buffer, buffer_size, 0x20); } -size_t cbor_encode_negint32(uint32_t value, unsigned char *buffer, +size_t cbor_encode_negint32(uint32_t value, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint32(value, buffer, buffer_size, 0x20); } -size_t cbor_encode_negint64(uint64_t value, unsigned char *buffer, +size_t cbor_encode_negint64(uint64_t value, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint64(value, buffer, buffer_size, 0x20); } -size_t cbor_encode_negint(uint64_t value, unsigned char *buffer, +size_t cbor_encode_negint(uint64_t value, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint(value, buffer, buffer_size, 0x20); } -size_t cbor_encode_bytestring_start(size_t length, unsigned char *buffer, +size_t cbor_encode_bytestring_start(size_t length, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint((size_t)length, buffer, buffer_size, 0x40); } -size_t _cbor_encode_byte(uint8_t value, unsigned char *buffer, +size_t _cbor_encode_byte(uint8_t value, unsigned char* buffer, size_t buffer_size) { if (buffer_size >= 1) { buffer[0] = value; @@ -72,60 +75,61 @@ size_t _cbor_encode_byte(uint8_t value, unsigned char *buffer, return 0; } -size_t cbor_encode_indef_bytestring_start(unsigned char *buffer, +size_t cbor_encode_indef_bytestring_start(unsigned char* buffer, size_t buffer_size) { return _cbor_encode_byte(0x5F, buffer, buffer_size); } -size_t cbor_encode_string_start(size_t length, unsigned char *buffer, +size_t cbor_encode_string_start(size_t length, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint((size_t)length, buffer, buffer_size, 0x60); } -size_t cbor_encode_indef_string_start(unsigned char *buffer, +size_t cbor_encode_indef_string_start(unsigned char* buffer, size_t buffer_size) { return _cbor_encode_byte(0x7F, buffer, buffer_size); } -size_t cbor_encode_array_start(size_t length, unsigned char *buffer, +size_t cbor_encode_array_start(size_t length, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint((size_t)length, buffer, buffer_size, 0x80); } -size_t cbor_encode_indef_array_start(unsigned char *buffer, +size_t cbor_encode_indef_array_start(unsigned char* buffer, size_t buffer_size) { return _cbor_encode_byte(0x9F, buffer, buffer_size); } -size_t cbor_encode_map_start(size_t length, unsigned char *buffer, +size_t cbor_encode_map_start(size_t length, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint((size_t)length, buffer, buffer_size, 0xA0); } -size_t cbor_encode_indef_map_start(unsigned char *buffer, size_t buffer_size) { +size_t cbor_encode_indef_map_start(unsigned char* buffer, size_t buffer_size) { return _cbor_encode_byte(0xBF, buffer, buffer_size); } -size_t cbor_encode_tag(uint64_t value, unsigned char *buffer, +size_t cbor_encode_tag(uint64_t value, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint(value, buffer, buffer_size, 0xC0); } -size_t cbor_encode_bool(bool value, unsigned char *buffer, size_t buffer_size) { +size_t cbor_encode_bool(bool value, unsigned char* buffer, size_t buffer_size) { return value ? _cbor_encode_byte(0xF5, buffer, buffer_size) : _cbor_encode_byte(0xF4, buffer, buffer_size); } -size_t cbor_encode_null(unsigned char *buffer, size_t buffer_size) { +size_t cbor_encode_null(unsigned char* buffer, size_t buffer_size) { return _cbor_encode_byte(0xF6, buffer, buffer_size); } -size_t cbor_encode_undef(unsigned char *buffer, size_t buffer_size) { +size_t cbor_encode_undef(unsigned char* buffer, size_t buffer_size) { return _cbor_encode_byte(0xF7, buffer, buffer_size); } -size_t cbor_encode_half(float value, unsigned char *buffer, +size_t cbor_encode_half(float value, unsigned char* buffer, size_t buffer_size) { + // TODO: Broken on systems that do not use IEEE 754 /* Assuming value is normalized */ uint32_t val = ((union _cbor_float_helper){.as_float = value}).as_uint; uint16_t res; @@ -134,11 +138,8 @@ size_t cbor_encode_half(float value, unsigned char *buffer, uint32_t mant = val & 0x7FFFFFu; /* 0b0000_0000_0111_1111_1111_1111_1111_1111 */ if (exp == 0xFF) { /* Infinity or NaNs */ - if (value != value) { - // We discard information bits in half-float NaNs. This is - // not required for the core CBOR protocol (it is only a suggestion in - // Section 3.9). - // See https://github.com/PJK/libcbor/issues/215 + if (isnan(value)) { + // Note: Values of signaling NaNs are discarded. See `cbor_encode_single`. res = (uint16_t)0x007e00; } else { // If the mantissa is non-zero, we have a NaN, but those are handled @@ -176,25 +177,38 @@ size_t cbor_encode_half(float value, unsigned char *buffer, return _cbor_encode_uint16(res, buffer, buffer_size, 0xE0); } -size_t cbor_encode_single(float value, unsigned char *buffer, +size_t cbor_encode_single(float value, unsigned char* buffer, size_t buffer_size) { + // Note: Values of signaling NaNs are discarded. There is no standard + // way to extract it without assumptions about the internal float + // representation. + if (isnan(value)) { + return _cbor_encode_uint32(0x7FC0 << 16, buffer, buffer_size, 0xE0); + } + // TODO: Broken on systems that do not use IEEE 754 return _cbor_encode_uint32( ((union _cbor_float_helper){.as_float = value}).as_uint, buffer, buffer_size, 0xE0); } -size_t cbor_encode_double(double value, unsigned char *buffer, +size_t cbor_encode_double(double value, unsigned char* buffer, size_t buffer_size) { + // Note: Values of signaling NaNs are discarded. See `cbor_encode_single`. + if (isnan(value)) { + return _cbor_encode_uint64((uint64_t)0x7FF8 << 48, buffer, buffer_size, + 0xE0); + } + // TODO: Broken on systems that do not use IEEE 754 return _cbor_encode_uint64( ((union _cbor_double_helper){.as_double = value}).as_uint, buffer, buffer_size, 0xE0); } -size_t cbor_encode_break(unsigned char *buffer, size_t buffer_size) { +size_t cbor_encode_break(unsigned char* buffer, size_t buffer_size) { return _cbor_encode_byte(0xFF, buffer, buffer_size); } -size_t cbor_encode_ctrl(uint8_t value, unsigned char *buffer, +size_t cbor_encode_ctrl(uint8_t value, unsigned char* buffer, size_t buffer_size) { return _cbor_encode_uint8(value, buffer, buffer_size, 0xE0); } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/encoding.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/encoding.h index bcc04f8a98e..c05bbc54573 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/encoding.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/encoding.h @@ -27,76 +27,72 @@ extern "C" { * case it is not modified). */ -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_uint8(uint8_t, unsigned char *, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_uint8(uint8_t, unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_uint16(uint16_t, unsigned char *, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_uint16(uint16_t, unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_uint32(uint32_t, unsigned char *, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_uint32(uint32_t, unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_uint64(uint64_t, unsigned char *, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_uint64(uint64_t, unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_uint(uint64_t, unsigned char *, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_uint(uint64_t, unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_negint8(uint8_t, unsigned char *, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_negint8(uint8_t, unsigned char*, size_t); _CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_negint16(uint16_t, - unsigned char *, - size_t); + unsigned char*, size_t); _CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_negint32(uint32_t, - unsigned char *, - size_t); + unsigned char*, size_t); _CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_negint64(uint64_t, - unsigned char *, - size_t); + unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_negint(uint64_t, unsigned char *, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_negint(uint64_t, unsigned char*, size_t); _CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_bytestring_start(size_t, - unsigned char *, + unsigned char*, size_t); _CBOR_NODISCARD CBOR_EXPORT size_t -cbor_encode_indef_bytestring_start(unsigned char *, size_t); +cbor_encode_indef_bytestring_start(unsigned char*, size_t); _CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_string_start(size_t, - unsigned char *, + unsigned char*, size_t); _CBOR_NODISCARD CBOR_EXPORT size_t -cbor_encode_indef_string_start(unsigned char *, size_t); +cbor_encode_indef_string_start(unsigned char*, size_t); _CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_array_start(size_t, - unsigned char *, + unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t -cbor_encode_indef_array_start(unsigned char *, size_t); +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_indef_array_start(unsigned char*, + size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_map_start(size_t, - unsigned char *, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_map_start(size_t, unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_indef_map_start(unsigned char *, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_indef_map_start(unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_tag(uint64_t, unsigned char *, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_tag(uint64_t, unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_bool(bool, unsigned char *, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_bool(bool, unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_null(unsigned char *, size_t); +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_null(unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_undef(unsigned char *, size_t); +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_undef(unsigned char*, size_t); /** Encodes a half-precision float * @@ -118,19 +114,28 @@ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_undef(unsigned char *, size_t); * lost. * - In all other cases, the sign bit, the exponent, and 10 most significant * bits of the significand are kept + * + * Note: Signaling NaNs are encoded as a standard, "quiet" NaN. */ -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_half(float, unsigned char *, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_half(float, unsigned char*, size_t); - -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_single(float, unsigned char *, +/** Encodes a single precision float + * + * Note: Signaling NaNs are encoded as a standard, "quiet" NaN. + */ +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_single(float, unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_double(double, unsigned char *, +/** Encodes a double precision float + * + * Note: Signaling NaNs are encoded as a standard, "quiet" NaN. + */ +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_double(double, unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_break(unsigned char *, size_t); +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_break(unsigned char*, size_t); -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_ctrl(uint8_t, unsigned char *, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_encode_ctrl(uint8_t, unsigned char*, size_t); #ifdef __cplusplus diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/floats_ctrls.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/floats_ctrls.c index 57bf477d4d3..705e78cb20c 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/floats_ctrls.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/floats_ctrls.c @@ -9,43 +9,42 @@ #include <math.h> #include "assert.h" -cbor_float_width cbor_float_get_width(const cbor_item_t *item) { +cbor_float_width cbor_float_get_width(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_float_ctrl(item)); return item->metadata.float_ctrl_metadata.width; } -uint8_t cbor_ctrl_value(const cbor_item_t *item) { +uint8_t cbor_ctrl_value(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_float_ctrl(item)); CBOR_ASSERT(cbor_float_get_width(item) == CBOR_FLOAT_0); return item->metadata.float_ctrl_metadata.ctrl; } -bool cbor_float_ctrl_is_ctrl(const cbor_item_t *item) { +bool cbor_float_ctrl_is_ctrl(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_float_ctrl(item)); return cbor_float_get_width(item) == CBOR_FLOAT_0; } -float cbor_float_get_float2(const cbor_item_t *item) { +float cbor_float_get_float2(const cbor_item_t* item) { CBOR_ASSERT(cbor_is_float(item)); CBOR_ASSERT(cbor_float_get_width(item) == CBOR_FLOAT_16); - return *(float *)item->data; + return *(float*)item->data; } -float cbor_float_get_float4(const cbor_item_t *item) { +float cbor_float_get_float4(const cbor_item_t* item) { CBOR_ASSERT(cbor_is_float(item)); CBOR_ASSERT(cbor_float_get_width(item) == CBOR_FLOAT_32); - return *(float *)item->data; + return *(float*)item->data; } -double cbor_float_get_float8(const cbor_item_t *item) { +double cbor_float_get_float8(const cbor_item_t* item) { CBOR_ASSERT(cbor_is_float(item)); CBOR_ASSERT(cbor_float_get_width(item) == CBOR_FLOAT_64); - return *(double *)item->data; + return *(double*)item->data; } -double cbor_float_get_float(const cbor_item_t *item) { +double cbor_float_get_float(const cbor_item_t* item) { CBOR_ASSERT(cbor_is_float(item)); - // cppcheck-suppress missingReturn switch (cbor_float_get_width(item)) { case CBOR_FLOAT_0: return NAN; @@ -55,46 +54,49 @@ double cbor_float_get_float(const cbor_item_t *item) { return cbor_float_get_float4(item); case CBOR_FLOAT_64: return cbor_float_get_float8(item); + default: + _CBOR_UNREACHABLE; + return 0; } } -bool cbor_get_bool(const cbor_item_t *item) { +bool cbor_get_bool(const cbor_item_t* item) { CBOR_ASSERT(cbor_is_bool(item)); return item->metadata.float_ctrl_metadata.ctrl == CBOR_CTRL_TRUE; } -void cbor_set_float2(cbor_item_t *item, float value) { +void cbor_set_float2(cbor_item_t* item, float value) { CBOR_ASSERT(cbor_is_float(item)); CBOR_ASSERT(cbor_float_get_width(item) == CBOR_FLOAT_16); - *((float *)item->data) = value; + *((float*)item->data) = value; } -void cbor_set_float4(cbor_item_t *item, float value) { +void cbor_set_float4(cbor_item_t* item, float value) { CBOR_ASSERT(cbor_is_float(item)); CBOR_ASSERT(cbor_float_get_width(item) == CBOR_FLOAT_32); - *((float *)item->data) = value; + *((float*)item->data) = value; } -void cbor_set_float8(cbor_item_t *item, double value) { +void cbor_set_float8(cbor_item_t* item, double value) { CBOR_ASSERT(cbor_is_float(item)); CBOR_ASSERT(cbor_float_get_width(item) == CBOR_FLOAT_64); - *((double *)item->data) = value; + *((double*)item->data) = value; } -void cbor_set_ctrl(cbor_item_t *item, uint8_t value) { +void cbor_set_ctrl(cbor_item_t* item, uint8_t value) { CBOR_ASSERT(cbor_isa_float_ctrl(item)); CBOR_ASSERT(cbor_float_get_width(item) == CBOR_FLOAT_0); item->metadata.float_ctrl_metadata.ctrl = value; } -void cbor_set_bool(cbor_item_t *item, bool value) { +void cbor_set_bool(cbor_item_t* item, bool value) { CBOR_ASSERT(cbor_is_bool(item)); item->metadata.float_ctrl_metadata.ctrl = value ? CBOR_CTRL_TRUE : CBOR_CTRL_FALSE; } -cbor_item_t *cbor_new_ctrl(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t)); +cbor_item_t* cbor_new_ctrl(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t)); _CBOR_NOTNULL(item); *item = (cbor_item_t){ @@ -106,83 +108,83 @@ cbor_item_t *cbor_new_ctrl(void) { return item; } -cbor_item_t *cbor_new_float2(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t) + 4); +cbor_item_t* cbor_new_float2(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t) + 4); _CBOR_NOTNULL(item); *item = (cbor_item_t){ .type = CBOR_TYPE_FLOAT_CTRL, - .data = (unsigned char *)item + sizeof(cbor_item_t), + .data = (unsigned char*)item + sizeof(cbor_item_t), .refcount = 1, .metadata = {.float_ctrl_metadata = {.width = CBOR_FLOAT_16}}}; return item; } -cbor_item_t *cbor_new_float4(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t) + 4); +cbor_item_t* cbor_new_float4(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t) + 4); _CBOR_NOTNULL(item); *item = (cbor_item_t){ .type = CBOR_TYPE_FLOAT_CTRL, - .data = (unsigned char *)item + sizeof(cbor_item_t), + .data = (unsigned char*)item + sizeof(cbor_item_t), .refcount = 1, .metadata = {.float_ctrl_metadata = {.width = CBOR_FLOAT_32}}}; return item; } -cbor_item_t *cbor_new_float8(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t) + 8); +cbor_item_t* cbor_new_float8(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t) + 8); _CBOR_NOTNULL(item); *item = (cbor_item_t){ .type = CBOR_TYPE_FLOAT_CTRL, - .data = (unsigned char *)item + sizeof(cbor_item_t), + .data = (unsigned char*)item + sizeof(cbor_item_t), .refcount = 1, .metadata = {.float_ctrl_metadata = {.width = CBOR_FLOAT_64}}}; return item; } -cbor_item_t *cbor_new_null(void) { - cbor_item_t *item = cbor_new_ctrl(); +cbor_item_t* cbor_new_null(void) { + cbor_item_t* item = cbor_new_ctrl(); _CBOR_NOTNULL(item); cbor_set_ctrl(item, CBOR_CTRL_NULL); return item; } -cbor_item_t *cbor_new_undef(void) { - cbor_item_t *item = cbor_new_ctrl(); +cbor_item_t* cbor_new_undef(void) { + cbor_item_t* item = cbor_new_ctrl(); _CBOR_NOTNULL(item); cbor_set_ctrl(item, CBOR_CTRL_UNDEF); return item; } -cbor_item_t *cbor_build_bool(bool value) { +cbor_item_t* cbor_build_bool(bool value) { return cbor_build_ctrl(value ? CBOR_CTRL_TRUE : CBOR_CTRL_FALSE); } -cbor_item_t *cbor_build_float2(float value) { - cbor_item_t *item = cbor_new_float2(); +cbor_item_t* cbor_build_float2(float value) { + cbor_item_t* item = cbor_new_float2(); _CBOR_NOTNULL(item); cbor_set_float2(item, value); return item; } -cbor_item_t *cbor_build_float4(float value) { - cbor_item_t *item = cbor_new_float4(); +cbor_item_t* cbor_build_float4(float value) { + cbor_item_t* item = cbor_new_float4(); _CBOR_NOTNULL(item); cbor_set_float4(item, value); return item; } -cbor_item_t *cbor_build_float8(double value) { - cbor_item_t *item = cbor_new_float8(); +cbor_item_t* cbor_build_float8(double value) { + cbor_item_t* item = cbor_new_float8(); _CBOR_NOTNULL(item); cbor_set_float8(item, value); return item; } -cbor_item_t *cbor_build_ctrl(uint8_t value) { - cbor_item_t *item = cbor_new_ctrl(); +cbor_item_t* cbor_build_ctrl(uint8_t value) { + cbor_item_t* item = cbor_new_ctrl(); _CBOR_NOTNULL(item); cbor_set_ctrl(item, value); return item; diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/floats_ctrls.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/floats_ctrls.h index 335eab8328b..6a792534695 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/floats_ctrls.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/floats_ctrls.h @@ -27,7 +27,7 @@ extern "C" { * @return Is this a ctrl value? */ _CBOR_NODISCARD CBOR_EXPORT bool cbor_float_ctrl_is_ctrl( - const cbor_item_t *item); + const cbor_item_t* item); /** Get the float width * @@ -35,7 +35,7 @@ _CBOR_NODISCARD CBOR_EXPORT bool cbor_float_ctrl_is_ctrl( * @return The width. */ _CBOR_NODISCARD CBOR_EXPORT cbor_float_width -cbor_float_get_width(const cbor_item_t *item); +cbor_float_get_width(const cbor_item_t* item); /** Get a half precision float * @@ -45,7 +45,7 @@ cbor_float_get_width(const cbor_item_t *item); * @return half precision value */ _CBOR_NODISCARD CBOR_EXPORT float cbor_float_get_float2( - const cbor_item_t *item); + const cbor_item_t* item); /** Get a single precision float * @@ -55,7 +55,7 @@ _CBOR_NODISCARD CBOR_EXPORT float cbor_float_get_float2( * @return single precision value */ _CBOR_NODISCARD CBOR_EXPORT float cbor_float_get_float4( - const cbor_item_t *item); + const cbor_item_t* item); /** Get a double precision float * @@ -65,7 +65,7 @@ _CBOR_NODISCARD CBOR_EXPORT float cbor_float_get_float4( * @return double precision value */ _CBOR_NODISCARD CBOR_EXPORT double cbor_float_get_float8( - const cbor_item_t *item); + const cbor_item_t* item); /** Get the float value represented as double * @@ -75,14 +75,14 @@ _CBOR_NODISCARD CBOR_EXPORT double cbor_float_get_float8( * @return double precision value */ _CBOR_NODISCARD CBOR_EXPORT double cbor_float_get_float( - const cbor_item_t *item); + const cbor_item_t* item); /** Get value from a boolean ctrl item * * @param item A ctrl item * @return boolean value */ -_CBOR_NODISCARD CBOR_EXPORT bool cbor_get_bool(const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT bool cbor_get_bool(const cbor_item_t* item); /** Constructs a new ctrl item * @@ -92,7 +92,7 @@ _CBOR_NODISCARD CBOR_EXPORT bool cbor_get_bool(const cbor_item_t *item); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_ctrl(void); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_ctrl(void); /** Constructs a new float item * @@ -102,7 +102,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_ctrl(void); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_float2(void); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_float2(void); /** Constructs a new float item * @@ -112,7 +112,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_float2(void); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_float4(void); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_float4(void); /** Constructs a new float item * @@ -122,7 +122,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_float4(void); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_float8(void); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_float8(void); /** Constructs new null ctrl item * @@ -130,7 +130,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_float8(void); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_null(void); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_null(void); /** Constructs new undef ctrl item * @@ -138,7 +138,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_null(void); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_undef(void); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_undef(void); /** Constructs new boolean ctrl item * @@ -147,7 +147,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_undef(void); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_bool(bool value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_bool(bool value); /** Assign a control value * @@ -160,42 +160,42 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_bool(bool value); * @param value The simple value to assign. Please consult the standard for * allowed values */ -CBOR_EXPORT void cbor_set_ctrl(cbor_item_t *item, uint8_t value); +CBOR_EXPORT void cbor_set_ctrl(cbor_item_t* item, uint8_t value); /** Assign a boolean value to a boolean ctrl item * * @param item A ctrl item * @param value The simple value to assign. */ -CBOR_EXPORT void cbor_set_bool(cbor_item_t *item, bool value); +CBOR_EXPORT void cbor_set_bool(cbor_item_t* item, bool value); /** Assigns a float value * * @param item A half precision float * @param value The value to assign */ -CBOR_EXPORT void cbor_set_float2(cbor_item_t *item, float value); +CBOR_EXPORT void cbor_set_float2(cbor_item_t* item, float value); /** Assigns a float value * * @param item A single precision float * @param value The value to assign */ -CBOR_EXPORT void cbor_set_float4(cbor_item_t *item, float value); +CBOR_EXPORT void cbor_set_float4(cbor_item_t* item, float value); /** Assigns a float value * * @param item A double precision float * @param value The value to assign */ -CBOR_EXPORT void cbor_set_float8(cbor_item_t *item, double value); +CBOR_EXPORT void cbor_set_float8(cbor_item_t* item, double value); /** Reads the control value * * @param item A ctrl item * @return the simple value */ -_CBOR_NODISCARD CBOR_EXPORT uint8_t cbor_ctrl_value(const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT uint8_t cbor_ctrl_value(const cbor_item_t* item); /** Constructs a new float * @@ -204,7 +204,7 @@ _CBOR_NODISCARD CBOR_EXPORT uint8_t cbor_ctrl_value(const cbor_item_t *item); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_float2(float value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_float2(float value); /** Constructs a new float * @@ -213,7 +213,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_float2(float value); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_float4(float value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_float4(float value); /** Constructs a new float * @@ -222,7 +222,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_float4(float value); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_float8(double value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_float8(double value); /** Constructs a ctrl item * @@ -231,7 +231,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_float8(double value); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_ctrl(uint8_t value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_ctrl(uint8_t value); #ifdef __cplusplus } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/builder_callbacks.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/builder_callbacks.c index 257cef3adbd..24e7708da3e 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/builder_callbacks.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/builder_callbacks.c @@ -21,8 +21,8 @@ // `_cbor_builder_append` takes ownership of `item`. If adding the item to // parent container fails, `item` will be deallocated to prevent memory. -void _cbor_builder_append(cbor_item_t *item, - struct _cbor_decoder_context *ctx) { +void _cbor_builder_append(cbor_item_t* item, + struct _cbor_decoder_context* ctx) { if (ctx->stack->size == 0) { /* Top level item */ ctx->root = item; @@ -49,7 +49,7 @@ void _cbor_builder_append(cbor_item_t *item, cbor_decref(&item); ctx->stack->top->subitems--; if (ctx->stack->top->subitems == 0) { - cbor_item_t *stack_item = ctx->stack->top->item; + cbor_item_t* stack_item = ctx->stack->top->item; _cbor_stack_pop(ctx->stack); _cbor_builder_append(stack_item, ctx); } @@ -86,7 +86,7 @@ void _cbor_builder_append(cbor_item_t *item, CBOR_ASSERT(ctx->stack->top->subitems > 0); ctx->stack->top->subitems--; if (ctx->stack->top->subitems == 0) { - cbor_item_t *map_entry = ctx->stack->top->item; + cbor_item_t* map_entry = ctx->stack->top->item; _cbor_stack_pop(ctx->stack); _cbor_builder_append(map_entry, ctx); } @@ -100,7 +100,7 @@ void _cbor_builder_append(cbor_item_t *item, CBOR_ASSERT(ctx->stack->top->subitems == 1); cbor_tag_set_item(ctx->stack->top->item, item); cbor_decref(&item); /* Give up on our reference */ - cbor_item_t *tagged_item = ctx->stack->top->item; + cbor_item_t* tagged_item = ctx->stack->top->item; _cbor_stack_pop(ctx->stack); _cbor_builder_append(tagged_item, ctx); break; @@ -139,90 +139,90 @@ void _cbor_builder_append(cbor_item_t *item, } \ } while (0) -void cbor_builder_uint8_callback(void *context, uint8_t value) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_int8(); +void cbor_builder_uint8_callback(void* context, uint8_t value) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_int8(); CHECK_RES(ctx, res); cbor_mark_uint(res); cbor_set_uint8(res, value); _cbor_builder_append(res, ctx); } -void cbor_builder_uint16_callback(void *context, uint16_t value) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_int16(); +void cbor_builder_uint16_callback(void* context, uint16_t value) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_int16(); CHECK_RES(ctx, res); cbor_mark_uint(res); cbor_set_uint16(res, value); _cbor_builder_append(res, ctx); } -void cbor_builder_uint32_callback(void *context, uint32_t value) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_int32(); +void cbor_builder_uint32_callback(void* context, uint32_t value) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_int32(); CHECK_RES(ctx, res); cbor_mark_uint(res); cbor_set_uint32(res, value); _cbor_builder_append(res, ctx); } -void cbor_builder_uint64_callback(void *context, uint64_t value) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_int64(); +void cbor_builder_uint64_callback(void* context, uint64_t value) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_int64(); CHECK_RES(ctx, res); cbor_mark_uint(res); cbor_set_uint64(res, value); _cbor_builder_append(res, ctx); } -void cbor_builder_negint8_callback(void *context, uint8_t value) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_int8(); +void cbor_builder_negint8_callback(void* context, uint8_t value) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_int8(); CHECK_RES(ctx, res); cbor_mark_negint(res); cbor_set_uint8(res, value); _cbor_builder_append(res, ctx); } -void cbor_builder_negint16_callback(void *context, uint16_t value) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_int16(); +void cbor_builder_negint16_callback(void* context, uint16_t value) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_int16(); CHECK_RES(ctx, res); cbor_mark_negint(res); cbor_set_uint16(res, value); _cbor_builder_append(res, ctx); } -void cbor_builder_negint32_callback(void *context, uint32_t value) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_int32(); +void cbor_builder_negint32_callback(void* context, uint32_t value) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_int32(); CHECK_RES(ctx, res); cbor_mark_negint(res); cbor_set_uint32(res, value); _cbor_builder_append(res, ctx); } -void cbor_builder_negint64_callback(void *context, uint64_t value) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_int64(); +void cbor_builder_negint64_callback(void* context, uint64_t value) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_int64(); CHECK_RES(ctx, res); cbor_mark_negint(res); cbor_set_uint64(res, value); _cbor_builder_append(res, ctx); } -void cbor_builder_byte_string_callback(void *context, cbor_data data, +void cbor_builder_byte_string_callback(void* context, cbor_data data, uint64_t length) { - struct _cbor_decoder_context *ctx = context; + struct _cbor_decoder_context* ctx = context; CHECK_LENGTH(ctx, length); - unsigned char *new_handle = _cbor_malloc(length); + unsigned char* new_handle = _cbor_malloc(length); if (new_handle == NULL) { ctx->creation_failed = true; return; } memcpy(new_handle, data, length); - cbor_item_t *new_chunk = cbor_new_definite_bytestring(); + cbor_item_t* new_chunk = cbor_new_definite_bytestring(); if (new_chunk == NULL) { _cbor_free(new_handle); @@ -245,26 +245,26 @@ void cbor_builder_byte_string_callback(void *context, cbor_data data, } } -void cbor_builder_byte_string_start_callback(void *context) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_indefinite_bytestring(); +void cbor_builder_byte_string_start_callback(void* context) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_indefinite_bytestring(); CHECK_RES(ctx, res); PUSH_CTX_STACK(ctx, res, 0); } -void cbor_builder_string_callback(void *context, cbor_data data, +void cbor_builder_string_callback(void* context, cbor_data data, uint64_t length) { - struct _cbor_decoder_context *ctx = context; + struct _cbor_decoder_context* ctx = context; CHECK_LENGTH(ctx, length); - unsigned char *new_handle = _cbor_malloc(length); + unsigned char* new_handle = _cbor_malloc(length); if (new_handle == NULL) { ctx->creation_failed = true; return; } memcpy(new_handle, data, length); - cbor_item_t *new_chunk = cbor_new_definite_string(); + cbor_item_t* new_chunk = cbor_new_definite_string(); if (new_chunk == NULL) { _cbor_free(new_handle); ctx->creation_failed = true; @@ -285,17 +285,17 @@ void cbor_builder_string_callback(void *context, cbor_data data, } } -void cbor_builder_string_start_callback(void *context) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_indefinite_string(); +void cbor_builder_string_start_callback(void* context) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_indefinite_string(); CHECK_RES(ctx, res); PUSH_CTX_STACK(ctx, res, 0); } -void cbor_builder_array_start_callback(void *context, uint64_t size) { - struct _cbor_decoder_context *ctx = context; +void cbor_builder_array_start_callback(void* context, uint64_t size) { + struct _cbor_decoder_context* ctx = context; CHECK_LENGTH(ctx, size); - cbor_item_t *res = cbor_new_definite_array(size); + cbor_item_t* res = cbor_new_definite_array(size); CHECK_RES(ctx, res); if (size > 0) { PUSH_CTX_STACK(ctx, res, size); @@ -304,24 +304,24 @@ void cbor_builder_array_start_callback(void *context, uint64_t size) { } } -void cbor_builder_indef_array_start_callback(void *context) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_indefinite_array(); +void cbor_builder_indef_array_start_callback(void* context) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_indefinite_array(); CHECK_RES(ctx, res); PUSH_CTX_STACK(ctx, res, 0); } -void cbor_builder_indef_map_start_callback(void *context) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_indefinite_map(); +void cbor_builder_indef_map_start_callback(void* context) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_indefinite_map(); CHECK_RES(ctx, res); PUSH_CTX_STACK(ctx, res, 0); } -void cbor_builder_map_start_callback(void *context, uint64_t size) { - struct _cbor_decoder_context *ctx = context; +void cbor_builder_map_start_callback(void* context, uint64_t size) { + struct _cbor_decoder_context* ctx = context; CHECK_LENGTH(ctx, size); - cbor_item_t *res = cbor_new_definite_map(size); + cbor_item_t* res = cbor_new_definite_map(size); CHECK_RES(ctx, res); if (size > 0) { PUSH_CTX_STACK(ctx, res, size * 2); @@ -333,7 +333,7 @@ void cbor_builder_map_start_callback(void *context, uint64_t size) { /** * Is the (partially constructed) item indefinite? */ -bool _cbor_is_indefinite(cbor_item_t *item) { +bool _cbor_is_indefinite(cbor_item_t* item) { switch (item->type) { case CBOR_TYPE_BYTESTRING: return cbor_bytestring_is_indefinite(item); @@ -350,11 +350,11 @@ bool _cbor_is_indefinite(cbor_item_t *item) { } } -void cbor_builder_indef_break_callback(void *context) { - struct _cbor_decoder_context *ctx = context; +void cbor_builder_indef_break_callback(void* context) { + struct _cbor_decoder_context* ctx = context; /* There must be an item to break out of*/ if (ctx->stack->size > 0) { - cbor_item_t *item = ctx->stack->top->item; + cbor_item_t* item = ctx->stack->top->item; if (_cbor_is_indefinite( item) && /* Only indefinite items can be terminated by 0xFF */ /* Special case: we cannot append up if an indefinite map is incomplete @@ -369,54 +369,54 @@ void cbor_builder_indef_break_callback(void *context) { ctx->syntax_error = true; } -void cbor_builder_float2_callback(void *context, float value) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_float2(); +void cbor_builder_float2_callback(void* context, float value) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_float2(); CHECK_RES(ctx, res); cbor_set_float2(res, value); _cbor_builder_append(res, ctx); } -void cbor_builder_float4_callback(void *context, float value) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_float4(); +void cbor_builder_float4_callback(void* context, float value) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_float4(); CHECK_RES(ctx, res); cbor_set_float4(res, value); _cbor_builder_append(res, ctx); } -void cbor_builder_float8_callback(void *context, double value) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_float8(); +void cbor_builder_float8_callback(void* context, double value) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_float8(); CHECK_RES(ctx, res); cbor_set_float8(res, value); _cbor_builder_append(res, ctx); } -void cbor_builder_null_callback(void *context) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_null(); +void cbor_builder_null_callback(void* context) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_null(); CHECK_RES(ctx, res); _cbor_builder_append(res, ctx); } -void cbor_builder_undefined_callback(void *context) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_undef(); +void cbor_builder_undefined_callback(void* context) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_undef(); CHECK_RES(ctx, res); _cbor_builder_append(res, ctx); } -void cbor_builder_boolean_callback(void *context, bool value) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_build_bool(value); +void cbor_builder_boolean_callback(void* context, bool value) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_build_bool(value); CHECK_RES(ctx, res); _cbor_builder_append(res, ctx); } -void cbor_builder_tag_callback(void *context, uint64_t value) { - struct _cbor_decoder_context *ctx = context; - cbor_item_t *res = cbor_new_tag(value); +void cbor_builder_tag_callback(void* context, uint64_t value) { + struct _cbor_decoder_context* ctx = context; + cbor_item_t* res = cbor_new_tag(value); CHECK_RES(ctx, res); PUSH_CTX_STACK(ctx, res, 1); } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/builder_callbacks.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/builder_callbacks.h index 7893960e413..0e034306952 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/builder_callbacks.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/builder_callbacks.h @@ -22,61 +22,61 @@ struct _cbor_decoder_context { bool creation_failed; /** Stack expectation mismatch */ bool syntax_error; - cbor_item_t *root; - struct _cbor_stack *stack; + cbor_item_t* root; + struct _cbor_stack* stack; }; /** Internal helper: Append item to the top of the stack while handling errors. */ -void _cbor_builder_append(cbor_item_t *item, struct _cbor_decoder_context *ctx); +void _cbor_builder_append(cbor_item_t* item, struct _cbor_decoder_context* ctx); -void cbor_builder_uint8_callback(void *, uint8_t); +void cbor_builder_uint8_callback(void*, uint8_t); -void cbor_builder_uint16_callback(void *, uint16_t); +void cbor_builder_uint16_callback(void*, uint16_t); -void cbor_builder_uint32_callback(void *, uint32_t); +void cbor_builder_uint32_callback(void*, uint32_t); -void cbor_builder_uint64_callback(void *, uint64_t); +void cbor_builder_uint64_callback(void*, uint64_t); -void cbor_builder_negint8_callback(void *, uint8_t); +void cbor_builder_negint8_callback(void*, uint8_t); -void cbor_builder_negint16_callback(void *, uint16_t); +void cbor_builder_negint16_callback(void*, uint16_t); -void cbor_builder_negint32_callback(void *, uint32_t); +void cbor_builder_negint32_callback(void*, uint32_t); -void cbor_builder_negint64_callback(void *, uint64_t); +void cbor_builder_negint64_callback(void*, uint64_t); -void cbor_builder_string_callback(void *, cbor_data, uint64_t); +void cbor_builder_string_callback(void*, cbor_data, uint64_t); -void cbor_builder_string_start_callback(void *); +void cbor_builder_string_start_callback(void*); -void cbor_builder_byte_string_callback(void *, cbor_data, uint64_t); +void cbor_builder_byte_string_callback(void*, cbor_data, uint64_t); -void cbor_builder_byte_string_start_callback(void *); +void cbor_builder_byte_string_start_callback(void*); -void cbor_builder_array_start_callback(void *, uint64_t); +void cbor_builder_array_start_callback(void*, uint64_t); -void cbor_builder_indef_array_start_callback(void *); +void cbor_builder_indef_array_start_callback(void*); -void cbor_builder_map_start_callback(void *, uint64_t); +void cbor_builder_map_start_callback(void*, uint64_t); -void cbor_builder_indef_map_start_callback(void *); +void cbor_builder_indef_map_start_callback(void*); -void cbor_builder_tag_callback(void *, uint64_t); +void cbor_builder_tag_callback(void*, uint64_t); -void cbor_builder_float2_callback(void *, float); +void cbor_builder_float2_callback(void*, float); -void cbor_builder_float4_callback(void *, float); +void cbor_builder_float4_callback(void*, float); -void cbor_builder_float8_callback(void *, double); +void cbor_builder_float8_callback(void*, double); -void cbor_builder_null_callback(void *); +void cbor_builder_null_callback(void*); -void cbor_builder_undefined_callback(void *); +void cbor_builder_undefined_callback(void*); -void cbor_builder_boolean_callback(void *, bool); +void cbor_builder_boolean_callback(void*, bool); -void cbor_builder_indef_break_callback(void *); +void cbor_builder_indef_break_callback(void*); #ifdef __cplusplus } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/encoders.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/encoders.c index 49d4d7f33d2..773df7970c2 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/encoders.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/encoders.c @@ -6,9 +6,10 @@ */ #include "encoders.h" + #include <string.h> -size_t _cbor_encode_uint8(uint8_t value, unsigned char *buffer, +size_t _cbor_encode_uint8(uint8_t value, unsigned char* buffer, size_t buffer_size, uint8_t offset) { if (value <= 23) { if (buffer_size >= 1) { @@ -25,43 +26,43 @@ size_t _cbor_encode_uint8(uint8_t value, unsigned char *buffer, return 0; } -size_t _cbor_encode_uint16(uint16_t value, unsigned char *buffer, +size_t _cbor_encode_uint16(uint16_t value, unsigned char* buffer, size_t buffer_size, uint8_t offset) { - if (buffer_size >= 3) { - buffer[0] = 0x19 + offset; + if (buffer_size < 3) { + return 0; + } + buffer[0] = 0x19 + offset; #ifdef IS_BIG_ENDIAN - memcpy(buffer + 1, &value, 2); + memcpy(buffer + 1, &value, 2); #else - buffer[1] = (unsigned char)(value >> 8); - buffer[2] = (unsigned char)value; + buffer[1] = (unsigned char)(value >> 8); + buffer[2] = (unsigned char)value; #endif - return 3; - } else - return 0; + return 3; } -size_t _cbor_encode_uint32(uint32_t value, unsigned char *buffer, +size_t _cbor_encode_uint32(uint32_t value, unsigned char* buffer, size_t buffer_size, uint8_t offset) { - if (buffer_size >= 5) { - buffer[0] = 0x1A + offset; + if (buffer_size < 5) { + return 0; + } + buffer[0] = 0x1A + offset; #ifdef IS_BIG_ENDIAN - memcpy(buffer + 1, &value, 4); + memcpy(buffer + 1, &value, 4); #else - buffer[1] = (unsigned char)(value >> 24); - buffer[2] = (unsigned char)(value >> 16); - buffer[3] = (unsigned char)(value >> 8); - buffer[4] = (unsigned char)value; + buffer[1] = (unsigned char)(value >> 24); + buffer[2] = (unsigned char)(value >> 16); + buffer[3] = (unsigned char)(value >> 8); + buffer[4] = (unsigned char)value; #endif - return 5; - } else - return 0; + return 5; } -size_t _cbor_encode_uint64(uint64_t value, unsigned char *buffer, +size_t _cbor_encode_uint64(uint64_t value, unsigned char* buffer, size_t buffer_size, uint8_t offset) { if (buffer_size >= 9) { buffer[0] = 0x1B + offset; @@ -84,7 +85,7 @@ size_t _cbor_encode_uint64(uint64_t value, unsigned char *buffer, return 0; } -size_t _cbor_encode_uint(uint64_t value, unsigned char *buffer, +size_t _cbor_encode_uint(uint64_t value, unsigned char* buffer, size_t buffer_size, uint8_t offset) { if (value <= UINT16_MAX) if (value <= UINT8_MAX) diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/encoders.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/encoders.h index 7eadb712164..162b0bad2c1 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/encoders.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/encoders.h @@ -15,23 +15,23 @@ extern "C" { #endif _CBOR_NODISCARD -size_t _cbor_encode_uint8(uint8_t value, unsigned char *buffer, +size_t _cbor_encode_uint8(uint8_t value, unsigned char* buffer, size_t buffer_size, uint8_t offset); _CBOR_NODISCARD -size_t _cbor_encode_uint16(uint16_t value, unsigned char *buffer, +size_t _cbor_encode_uint16(uint16_t value, unsigned char* buffer, size_t buffer_size, uint8_t offset); _CBOR_NODISCARD -size_t _cbor_encode_uint32(uint32_t value, unsigned char *buffer, +size_t _cbor_encode_uint32(uint32_t value, unsigned char* buffer, size_t buffer_size, uint8_t offset); _CBOR_NODISCARD -size_t _cbor_encode_uint64(uint64_t value, unsigned char *buffer, +size_t _cbor_encode_uint64(uint64_t value, unsigned char* buffer, size_t buffer_size, uint8_t offset); _CBOR_NODISCARD -size_t _cbor_encode_uint(uint64_t value, unsigned char *buffer, +size_t _cbor_encode_uint(uint64_t value, unsigned char* buffer, size_t buffer_size, uint8_t offset); #ifdef __cplusplus diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/loaders.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/loaders.c index cfa173de790..b89cf72235c 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/loaders.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/loaders.c @@ -11,7 +11,7 @@ uint8_t _cbor_load_uint8(cbor_data source) { return (uint8_t)*source; } -uint16_t _cbor_load_uint16(const unsigned char *source) { +uint16_t _cbor_load_uint16(const unsigned char* source) { #ifdef IS_BIG_ENDIAN uint16_t result; memcpy(&result, source, 2); @@ -21,7 +21,7 @@ uint16_t _cbor_load_uint16(const unsigned char *source) { #endif } -uint32_t _cbor_load_uint32(const unsigned char *source) { +uint32_t _cbor_load_uint32(const unsigned char* source) { #ifdef IS_BIG_ENDIAN uint32_t result; memcpy(&result, source, 4); @@ -33,7 +33,7 @@ uint32_t _cbor_load_uint32(const unsigned char *source) { #endif } -uint64_t _cbor_load_uint64(const unsigned char *source) { +uint64_t _cbor_load_uint64(const unsigned char* source) { #ifdef IS_BIG_ENDIAN uint64_t result; memcpy(&result, source, 8); @@ -50,7 +50,9 @@ uint64_t _cbor_load_uint64(const unsigned char *source) { } /* As per https://www.rfc-editor.org/rfc/rfc8949.html#name-half-precision */ -float _cbor_decode_half(unsigned char *halfp) { +float _cbor_decode_half(unsigned char* halfp) { + // TODO: Broken if we are not on IEEE 754 + // (https://github.com/PJK/libcbor/issues/336) int half = (halfp[0] << 8) + halfp[1]; int exp = (half >> 10) & 0x1f; int mant = half & 0x3ff; @@ -66,15 +68,19 @@ float _cbor_decode_half(unsigned char *halfp) { float _cbor_load_half(cbor_data source) { /* Discard const */ - return _cbor_decode_half((unsigned char *)source); + return _cbor_decode_half((unsigned char*)source); } float _cbor_load_float(cbor_data source) { + // TODO: Broken if we are not on IEEE 754 + // (https://github.com/PJK/libcbor/issues/336) union _cbor_float_helper helper = {.as_uint = _cbor_load_uint32(source)}; return helper.as_float; } double _cbor_load_double(cbor_data source) { + // TODO: Broken if we are not on IEEE 754 + // (https://github.com/PJK/libcbor/issues/336) union _cbor_double_helper helper = {.as_uint = _cbor_load_uint64(source)}; return helper.as_double; } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/loaders.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/loaders.h index ce37563a3d8..9e8eb68e29a 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/loaders.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/loaders.h @@ -16,16 +16,16 @@ extern "C" { /* Read the given uint from the given location, no questions asked */ _CBOR_NODISCARD -uint8_t _cbor_load_uint8(const unsigned char *source); +uint8_t _cbor_load_uint8(const unsigned char* source); _CBOR_NODISCARD -uint16_t _cbor_load_uint16(const unsigned char *source); +uint16_t _cbor_load_uint16(const unsigned char* source); _CBOR_NODISCARD -uint32_t _cbor_load_uint32(const unsigned char *source); +uint32_t _cbor_load_uint32(const unsigned char* source); _CBOR_NODISCARD -uint64_t _cbor_load_uint64(const unsigned char *source); +uint64_t _cbor_load_uint64(const unsigned char* source); _CBOR_NODISCARD float _cbor_load_half(cbor_data source); diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/stack.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/stack.c index 2db03cbbf08..00e6aed5237 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/stack.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/stack.c @@ -11,18 +11,18 @@ struct _cbor_stack _cbor_stack_init(void) { return (struct _cbor_stack){.top = NULL, .size = 0}; } -void _cbor_stack_pop(struct _cbor_stack *stack) { - struct _cbor_stack_record *top = stack->top; +void _cbor_stack_pop(struct _cbor_stack* stack) { + struct _cbor_stack_record* top = stack->top; stack->top = stack->top->lower; _cbor_free(top); stack->size--; } -struct _cbor_stack_record *_cbor_stack_push(struct _cbor_stack *stack, - cbor_item_t *item, +struct _cbor_stack_record* _cbor_stack_push(struct _cbor_stack* stack, + cbor_item_t* item, size_t subitems) { if (stack->size == CBOR_MAX_STACK_SIZE) return NULL; - struct _cbor_stack_record *new_top = + struct _cbor_stack_record* new_top = _cbor_malloc(sizeof(struct _cbor_stack_record)); if (new_top == NULL) return NULL; diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/stack.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/stack.h index cf2206b40e5..7bc43ac09f9 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/stack.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/internal/stack.h @@ -17,9 +17,9 @@ extern "C" { /** Simple stack record for the parser */ struct _cbor_stack_record { /** Pointer to the parent stack frame */ - struct _cbor_stack_record *lower; + struct _cbor_stack_record* lower; /** Item under construction */ - cbor_item_t *item; + cbor_item_t* item; /** * How many outstanding subitems are expected. * @@ -33,17 +33,17 @@ struct _cbor_stack_record { /** Stack handle - contents and size */ struct _cbor_stack { - struct _cbor_stack_record *top; + struct _cbor_stack_record* top; size_t size; }; _CBOR_NODISCARD struct _cbor_stack _cbor_stack_init(void); -void _cbor_stack_pop(struct _cbor_stack *); +void _cbor_stack_pop(struct _cbor_stack*); _CBOR_NODISCARD -struct _cbor_stack_record *_cbor_stack_push(struct _cbor_stack *, cbor_item_t *, +struct _cbor_stack_record* _cbor_stack_push(struct _cbor_stack*, cbor_item_t*, size_t); #ifdef __cplusplus diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/ints.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/ints.c index b4d035a1897..272d82550c4 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/ints.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/ints.c @@ -7,36 +7,36 @@ #include "ints.h" -cbor_int_width cbor_int_get_width(const cbor_item_t *item) { +cbor_int_width cbor_int_get_width(const cbor_item_t* item) { CBOR_ASSERT(cbor_is_int(item)); return item->metadata.int_metadata.width; } -uint8_t cbor_get_uint8(const cbor_item_t *item) { +uint8_t cbor_get_uint8(const cbor_item_t* item) { CBOR_ASSERT(cbor_is_int(item)); CBOR_ASSERT(cbor_int_get_width(item) == CBOR_INT_8); return *item->data; } -uint16_t cbor_get_uint16(const cbor_item_t *item) { +uint16_t cbor_get_uint16(const cbor_item_t* item) { CBOR_ASSERT(cbor_is_int(item)); CBOR_ASSERT(cbor_int_get_width(item) == CBOR_INT_16); - return *(uint16_t *)item->data; + return *(uint16_t*)item->data; } -uint32_t cbor_get_uint32(const cbor_item_t *item) { +uint32_t cbor_get_uint32(const cbor_item_t* item) { CBOR_ASSERT(cbor_is_int(item)); CBOR_ASSERT(cbor_int_get_width(item) == CBOR_INT_32); - return *(uint32_t *)item->data; + return *(uint32_t*)item->data; } -uint64_t cbor_get_uint64(const cbor_item_t *item) { +uint64_t cbor_get_uint64(const cbor_item_t* item) { CBOR_ASSERT(cbor_is_int(item)); CBOR_ASSERT(cbor_int_get_width(item) == CBOR_INT_64); - return *(uint64_t *)item->data; + return *(uint64_t*)item->data; } -uint64_t cbor_get_int(const cbor_item_t *item) { +uint64_t cbor_get_int(const cbor_item_t* item) { CBOR_ASSERT(cbor_is_int(item)); // cppcheck-suppress missingReturn switch (cbor_int_get_width(item)) { @@ -48,141 +48,144 @@ uint64_t cbor_get_int(const cbor_item_t *item) { return cbor_get_uint32(item); case CBOR_INT_64: return cbor_get_uint64(item); + default: + _CBOR_UNREACHABLE; + return 0; } } -void cbor_set_uint8(cbor_item_t *item, uint8_t value) { +void cbor_set_uint8(cbor_item_t* item, uint8_t value) { CBOR_ASSERT(cbor_is_int(item)); CBOR_ASSERT(cbor_int_get_width(item) == CBOR_INT_8); *item->data = value; } -void cbor_set_uint16(cbor_item_t *item, uint16_t value) { +void cbor_set_uint16(cbor_item_t* item, uint16_t value) { CBOR_ASSERT(cbor_is_int(item)); CBOR_ASSERT(cbor_int_get_width(item) == CBOR_INT_16); - *(uint16_t *)item->data = value; + *(uint16_t*)item->data = value; } -void cbor_set_uint32(cbor_item_t *item, uint32_t value) { +void cbor_set_uint32(cbor_item_t* item, uint32_t value) { CBOR_ASSERT(cbor_is_int(item)); CBOR_ASSERT(cbor_int_get_width(item) == CBOR_INT_32); - *(uint32_t *)item->data = value; + *(uint32_t*)item->data = value; } -void cbor_set_uint64(cbor_item_t *item, uint64_t value) { +void cbor_set_uint64(cbor_item_t* item, uint64_t value) { CBOR_ASSERT(cbor_is_int(item)); CBOR_ASSERT(cbor_int_get_width(item) == CBOR_INT_64); - *(uint64_t *)item->data = value; + *(uint64_t*)item->data = value; } -void cbor_mark_uint(cbor_item_t *item) { +void cbor_mark_uint(cbor_item_t* item) { CBOR_ASSERT(cbor_is_int(item)); item->type = CBOR_TYPE_UINT; } -void cbor_mark_negint(cbor_item_t *item) { +void cbor_mark_negint(cbor_item_t* item) { CBOR_ASSERT(cbor_is_int(item)); item->type = CBOR_TYPE_NEGINT; } -cbor_item_t *cbor_new_int8(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t) + 1); +cbor_item_t* cbor_new_int8(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t) + 1); _CBOR_NOTNULL(item); - *item = (cbor_item_t){.data = (unsigned char *)item + sizeof(cbor_item_t), + *item = (cbor_item_t){.data = (unsigned char*)item + sizeof(cbor_item_t), .refcount = 1, .metadata = {.int_metadata = {.width = CBOR_INT_8}}, .type = CBOR_TYPE_UINT}; return item; } -cbor_item_t *cbor_new_int16(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t) + 2); +cbor_item_t* cbor_new_int16(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t) + 2); _CBOR_NOTNULL(item); - *item = (cbor_item_t){.data = (unsigned char *)item + sizeof(cbor_item_t), + *item = (cbor_item_t){.data = (unsigned char*)item + sizeof(cbor_item_t), .refcount = 1, .metadata = {.int_metadata = {.width = CBOR_INT_16}}, .type = CBOR_TYPE_UINT}; return item; } -cbor_item_t *cbor_new_int32(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t) + 4); +cbor_item_t* cbor_new_int32(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t) + 4); _CBOR_NOTNULL(item); - *item = (cbor_item_t){.data = (unsigned char *)item + sizeof(cbor_item_t), + *item = (cbor_item_t){.data = (unsigned char*)item + sizeof(cbor_item_t), .refcount = 1, .metadata = {.int_metadata = {.width = CBOR_INT_32}}, .type = CBOR_TYPE_UINT}; return item; } -cbor_item_t *cbor_new_int64(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t) + 8); +cbor_item_t* cbor_new_int64(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t) + 8); _CBOR_NOTNULL(item); - *item = (cbor_item_t){.data = (unsigned char *)item + sizeof(cbor_item_t), + *item = (cbor_item_t){.data = (unsigned char*)item + sizeof(cbor_item_t), .refcount = 1, .metadata = {.int_metadata = {.width = CBOR_INT_64}}, .type = CBOR_TYPE_UINT}; return item; } -cbor_item_t *cbor_build_uint8(uint8_t value) { - cbor_item_t *item = cbor_new_int8(); +cbor_item_t* cbor_build_uint8(uint8_t value) { + cbor_item_t* item = cbor_new_int8(); _CBOR_NOTNULL(item); cbor_set_uint8(item, value); cbor_mark_uint(item); return item; } -cbor_item_t *cbor_build_uint16(uint16_t value) { - cbor_item_t *item = cbor_new_int16(); +cbor_item_t* cbor_build_uint16(uint16_t value) { + cbor_item_t* item = cbor_new_int16(); _CBOR_NOTNULL(item); cbor_set_uint16(item, value); cbor_mark_uint(item); return item; } -cbor_item_t *cbor_build_uint32(uint32_t value) { - cbor_item_t *item = cbor_new_int32(); +cbor_item_t* cbor_build_uint32(uint32_t value) { + cbor_item_t* item = cbor_new_int32(); _CBOR_NOTNULL(item); cbor_set_uint32(item, value); cbor_mark_uint(item); return item; } -cbor_item_t *cbor_build_uint64(uint64_t value) { - cbor_item_t *item = cbor_new_int64(); +cbor_item_t* cbor_build_uint64(uint64_t value) { + cbor_item_t* item = cbor_new_int64(); _CBOR_NOTNULL(item); cbor_set_uint64(item, value); cbor_mark_uint(item); return item; } -cbor_item_t *cbor_build_negint8(uint8_t value) { - cbor_item_t *item = cbor_new_int8(); +cbor_item_t* cbor_build_negint8(uint8_t value) { + cbor_item_t* item = cbor_new_int8(); _CBOR_NOTNULL(item); cbor_set_uint8(item, value); cbor_mark_negint(item); return item; } -cbor_item_t *cbor_build_negint16(uint16_t value) { - cbor_item_t *item = cbor_new_int16(); +cbor_item_t* cbor_build_negint16(uint16_t value) { + cbor_item_t* item = cbor_new_int16(); _CBOR_NOTNULL(item); cbor_set_uint16(item, value); cbor_mark_negint(item); return item; } -cbor_item_t *cbor_build_negint32(uint32_t value) { - cbor_item_t *item = cbor_new_int32(); +cbor_item_t* cbor_build_negint32(uint32_t value) { + cbor_item_t* item = cbor_new_int32(); _CBOR_NOTNULL(item); cbor_set_uint32(item, value); cbor_mark_negint(item); return item; } -cbor_item_t *cbor_build_negint64(uint64_t value) { - cbor_item_t *item = cbor_new_int64(); +cbor_item_t* cbor_build_negint64(uint64_t value) { + cbor_item_t* item = cbor_new_int64(); _CBOR_NOTNULL(item); cbor_set_uint64(item, value); cbor_mark_negint(item); diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/ints.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/ints.h index 006aa428e0a..30d061035fe 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/ints.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/ints.h @@ -26,35 +26,35 @@ extern "C" { * @param item positive or negative integer * @return the value */ -_CBOR_NODISCARD CBOR_EXPORT uint8_t cbor_get_uint8(const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT uint8_t cbor_get_uint8(const cbor_item_t* item); /** Extracts the integer value * * @param item positive or negative integer * @return the value */ -_CBOR_NODISCARD CBOR_EXPORT uint16_t cbor_get_uint16(const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT uint16_t cbor_get_uint16(const cbor_item_t* item); /** Extracts the integer value * * @param item positive or negative integer * @return the value */ -_CBOR_NODISCARD CBOR_EXPORT uint32_t cbor_get_uint32(const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT uint32_t cbor_get_uint32(const cbor_item_t* item); /** Extracts the integer value * * @param item positive or negative integer * @return the value */ -_CBOR_NODISCARD CBOR_EXPORT uint64_t cbor_get_uint64(const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT uint64_t cbor_get_uint64(const cbor_item_t* item); /** Extracts the integer value * * @param item positive or negative integer * @return the value, extended to `uint64_t` */ -_CBOR_NODISCARD CBOR_EXPORT uint64_t cbor_get_int(const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT uint64_t cbor_get_int(const cbor_item_t* item); /** Assigns the integer value * @@ -62,7 +62,7 @@ _CBOR_NODISCARD CBOR_EXPORT uint64_t cbor_get_int(const cbor_item_t *item); * @param value the value to assign. For negative integer, the logical value is * `-value - 1` */ -CBOR_EXPORT void cbor_set_uint8(cbor_item_t *item, uint8_t value); +CBOR_EXPORT void cbor_set_uint8(cbor_item_t* item, uint8_t value); /** Assigns the integer value * @@ -70,7 +70,7 @@ CBOR_EXPORT void cbor_set_uint8(cbor_item_t *item, uint8_t value); * @param value the value to assign. For negative integer, the logical value is * `-value - 1` */ -CBOR_EXPORT void cbor_set_uint16(cbor_item_t *item, uint16_t value); +CBOR_EXPORT void cbor_set_uint16(cbor_item_t* item, uint16_t value); /** Assigns the integer value * @@ -78,7 +78,7 @@ CBOR_EXPORT void cbor_set_uint16(cbor_item_t *item, uint16_t value); * @param value the value to assign. For negative integer, the logical value is * `-value - 1` */ -CBOR_EXPORT void cbor_set_uint32(cbor_item_t *item, uint32_t value); +CBOR_EXPORT void cbor_set_uint32(cbor_item_t* item, uint32_t value); /** Assigns the integer value * @@ -86,7 +86,7 @@ CBOR_EXPORT void cbor_set_uint32(cbor_item_t *item, uint32_t value); * @param value the value to assign. For negative integer, the logical value is * `-value - 1` */ -CBOR_EXPORT void cbor_set_uint64(cbor_item_t *item, uint64_t value); +CBOR_EXPORT void cbor_set_uint64(cbor_item_t* item, uint64_t value); /** Queries the integer width * @@ -94,7 +94,7 @@ CBOR_EXPORT void cbor_set_uint64(cbor_item_t *item, uint64_t value); * @return the width */ _CBOR_NODISCARD CBOR_EXPORT cbor_int_width -cbor_int_get_width(const cbor_item_t *item); +cbor_int_get_width(const cbor_item_t* item); /** Marks the integer item as a positive integer * @@ -102,7 +102,7 @@ cbor_int_get_width(const cbor_item_t *item); * * @param item positive or negative integer item */ -CBOR_EXPORT void cbor_mark_uint(cbor_item_t *item); +CBOR_EXPORT void cbor_mark_uint(cbor_item_t* item); /** Marks the integer item as a negative integer * @@ -110,7 +110,7 @@ CBOR_EXPORT void cbor_mark_uint(cbor_item_t *item); * * @param item positive or negative integer item */ -CBOR_EXPORT void cbor_mark_negint(cbor_item_t *item); +CBOR_EXPORT void cbor_mark_negint(cbor_item_t* item); /** Allocates new integer with 1B width * @@ -119,7 +119,7 @@ CBOR_EXPORT void cbor_mark_negint(cbor_item_t *item); * @return **new** positive integer or `NULL` on memory allocation failure. The * value is not initialized */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_int8(void); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_int8(void); /** Allocates new integer with 2B width * @@ -128,7 +128,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_int8(void); * @return **new** positive integer or `NULL` on memory allocation failure. The * value is not initialized */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_int16(void); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_int16(void); /** Allocates new integer with 4B width * @@ -137,7 +137,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_int16(void); * @return **new** positive integer or `NULL` on memory allocation failure. The * value is not initialized */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_int32(void); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_int32(void); /** Allocates new integer with 8B width * @@ -146,63 +146,63 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_int32(void); * @return **new** positive integer or `NULL` on memory allocation failure. The * value is not initialized */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_int64(void); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_int64(void); /** Constructs a new positive integer * * @param value the value to use * @return **new** positive integer or `NULL` on memory allocation failure */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_uint8(uint8_t value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_uint8(uint8_t value); /** Constructs a new positive integer * * @param value the value to use * @return **new** positive integer or `NULL` on memory allocation failure */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_uint16(uint16_t value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_uint16(uint16_t value); /** Constructs a new positive integer * * @param value the value to use * @return **new** positive integer or `NULL` on memory allocation failure */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_uint32(uint32_t value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_uint32(uint32_t value); /** Constructs a new positive integer * * @param value the value to use * @return **new** positive integer or `NULL` on memory allocation failure */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_uint64(uint64_t value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_uint64(uint64_t value); /** Constructs a new negative integer * * @param value the value to use * @return **new** negative integer or `NULL` on memory allocation failure */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_negint8(uint8_t value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_negint8(uint8_t value); /** Constructs a new negative integer * * @param value the value to use * @return **new** negative integer or `NULL` on memory allocation failure */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_negint16(uint16_t value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_negint16(uint16_t value); /** Constructs a new negative integer * * @param value the value to use * @return **new** negative integer or `NULL` on memory allocation failure */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_negint32(uint32_t value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_negint32(uint32_t value); /** Constructs a new negative integer * * @param value the value to use * @return **new** negative integer or `NULL` on memory allocation failure */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_negint64(uint64_t value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_negint64(uint64_t value); #ifdef __cplusplus } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/maps.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/maps.c index 8a3bd607568..7ce168a1ed7 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/maps.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/maps.c @@ -8,18 +8,18 @@ #include "maps.h" #include "internal/memory_utils.h" -size_t cbor_map_size(const cbor_item_t *item) { +size_t cbor_map_size(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_map(item)); return item->metadata.map_metadata.end_ptr; } -size_t cbor_map_allocated(const cbor_item_t *item) { +size_t cbor_map_allocated(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_map(item)); return item->metadata.map_metadata.allocated; } -cbor_item_t *cbor_new_definite_map(size_t size) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t)); +cbor_item_t* cbor_new_definite_map(size_t size) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t)); _CBOR_NOTNULL(item); *item = (cbor_item_t){ @@ -34,8 +34,8 @@ cbor_item_t *cbor_new_definite_map(size_t size) { return item; } -cbor_item_t *cbor_new_indefinite_map(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t)); +cbor_item_t* cbor_new_indefinite_map(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t)); _CBOR_NOTNULL(item); *item = (cbor_item_t){ @@ -49,12 +49,12 @@ cbor_item_t *cbor_new_indefinite_map(void) { return item; } -bool _cbor_map_add_key(cbor_item_t *item, cbor_item_t *key) { +bool _cbor_map_add_key(cbor_item_t* item, cbor_item_t* key) { CBOR_ASSERT(cbor_isa_map(item)); - struct _cbor_map_metadata *metadata = - (struct _cbor_map_metadata *)&item->metadata; + struct _cbor_map_metadata* metadata = + (struct _cbor_map_metadata*)&item->metadata; if (cbor_map_is_definite(item)) { - struct cbor_pair *data = cbor_map_handle(item); + struct cbor_pair* data = cbor_map_handle(item); if (metadata->end_ptr >= metadata->allocated) { /* Don't realloc definite preallocated map */ return false; @@ -74,7 +74,7 @@ bool _cbor_map_add_key(cbor_item_t *item, cbor_item_t *key) { ? 1 : CBOR_BUFFER_GROWTH * metadata->allocated; - unsigned char *new_data = _cbor_realloc_multiple( + unsigned char* new_data = _cbor_realloc_multiple( item->data, sizeof(struct cbor_pair), new_allocation); if (new_data == NULL) { @@ -84,7 +84,7 @@ bool _cbor_map_add_key(cbor_item_t *item, cbor_item_t *key) { item->data = new_data; metadata->allocated = new_allocation; } - struct cbor_pair *data = cbor_map_handle(item); + struct cbor_pair* data = cbor_map_handle(item); data[metadata->end_ptr].key = key; data[metadata->end_ptr++].value = NULL; } @@ -92,7 +92,7 @@ bool _cbor_map_add_key(cbor_item_t *item, cbor_item_t *key) { return true; } -bool _cbor_map_add_value(cbor_item_t *item, cbor_item_t *value) { +bool _cbor_map_add_value(cbor_item_t* item, cbor_item_t* value) { CBOR_ASSERT(cbor_isa_map(item)); cbor_incref(value); cbor_map_handle(item)[ @@ -104,22 +104,22 @@ bool _cbor_map_add_value(cbor_item_t *item, cbor_item_t *value) { } // TODO: Add a more convenient API like add(item, key, val) -bool cbor_map_add(cbor_item_t *item, struct cbor_pair pair) { +bool cbor_map_add(cbor_item_t* item, struct cbor_pair pair) { CBOR_ASSERT(cbor_isa_map(item)); if (!_cbor_map_add_key(item, pair.key)) return false; return _cbor_map_add_value(item, pair.value); } -bool cbor_map_is_definite(const cbor_item_t *item) { +bool cbor_map_is_definite(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_map(item)); return item->metadata.map_metadata.type == _CBOR_METADATA_DEFINITE; } -bool cbor_map_is_indefinite(const cbor_item_t *item) { +bool cbor_map_is_indefinite(const cbor_item_t* item) { return !cbor_map_is_definite(item); } -struct cbor_pair *cbor_map_handle(const cbor_item_t *item) { +struct cbor_pair* cbor_map_handle(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_map(item)); - return (struct cbor_pair *)item->data; + return (struct cbor_pair*)item->data; } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/maps.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/maps.h index 5c05b542bd8..d8b5f53b9e2 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/maps.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/maps.h @@ -26,14 +26,14 @@ extern "C" { * @param item A map * @return The number of pairs */ -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_map_size(const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_map_size(const cbor_item_t* item); /** Get the size of the allocated storage * * @param item A map * @return Allocated storage size (as the number of #cbor_pair items) */ -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_map_allocated(const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_map_allocated(const cbor_item_t* item); /** Create a new definite map * @@ -42,7 +42,7 @@ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_map_allocated(const cbor_item_t *item); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_definite_map(size_t size); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_definite_map(size_t size); /** Create a new indefinite map * @@ -50,7 +50,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_definite_map(size_t size); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_indefinite_map(void); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_indefinite_map(void); /** Add a pair to the map * @@ -63,7 +63,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_indefinite_map(void); * @return `true` on success, `false` if memory allocation failed (indefinite * maps) or the preallocated storage is full (definite maps) */ -_CBOR_NODISCARD CBOR_EXPORT bool cbor_map_add(cbor_item_t *item, +_CBOR_NODISCARD CBOR_EXPORT bool cbor_map_add(cbor_item_t* item, struct cbor_pair pair); /** Add a key to the map @@ -75,8 +75,8 @@ _CBOR_NODISCARD CBOR_EXPORT bool cbor_map_add(cbor_item_t *item, * @return `true` on success, `false` if either reallocation failed or the * preallocated storage is full */ -_CBOR_NODISCARD CBOR_EXPORT bool _cbor_map_add_key(cbor_item_t *item, - cbor_item_t *key); +_CBOR_NODISCARD CBOR_EXPORT bool _cbor_map_add_key(cbor_item_t* item, + cbor_item_t* key); /** Add a value to the map * @@ -87,15 +87,15 @@ _CBOR_NODISCARD CBOR_EXPORT bool _cbor_map_add_key(cbor_item_t *item, * @return `true` on success, `false` if either reallocation failed or the * preallocated storage is full */ -_CBOR_NODISCARD CBOR_EXPORT bool _cbor_map_add_value(cbor_item_t *item, - cbor_item_t *value); +_CBOR_NODISCARD CBOR_EXPORT bool _cbor_map_add_value(cbor_item_t* item, + cbor_item_t* value); /** Is this map definite? * * @param item A map * @return Is this map definite? */ -_CBOR_NODISCARD CBOR_EXPORT bool cbor_map_is_definite(const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT bool cbor_map_is_definite(const cbor_item_t* item); /** Is this map indefinite? * @@ -103,7 +103,7 @@ _CBOR_NODISCARD CBOR_EXPORT bool cbor_map_is_definite(const cbor_item_t *item); * @return Is this map indefinite? */ _CBOR_NODISCARD CBOR_EXPORT bool cbor_map_is_indefinite( - const cbor_item_t *item); + const cbor_item_t* item); /** Get the pairs storage * @@ -111,8 +111,8 @@ _CBOR_NODISCARD CBOR_EXPORT bool cbor_map_is_indefinite( * @return Array of #cbor_map_size pairs. Manipulation is possible as long as * references remain valid. */ -_CBOR_NODISCARD CBOR_EXPORT struct cbor_pair *cbor_map_handle( - const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT struct cbor_pair* cbor_map_handle( + const cbor_item_t* item); #ifdef __cplusplus } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/serialization.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/serialization.c index 40f4c531d57..dbfc8c37138 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/serialization.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/serialization.c @@ -17,9 +17,8 @@ #include "encoding.h" #include "internal/memory_utils.h" -size_t cbor_serialize(const cbor_item_t *item, unsigned char *buffer, +size_t cbor_serialize(const cbor_item_t* item, unsigned char* buffer, size_t buffer_size) { - // cppcheck-suppress missingReturn switch (cbor_typeof(item)) { case CBOR_TYPE_UINT: return cbor_serialize_uint(item, buffer, buffer_size); @@ -37,6 +36,9 @@ size_t cbor_serialize(const cbor_item_t *item, unsigned char *buffer, return cbor_serialize_tag(item, buffer, buffer_size); case CBOR_TYPE_FLOAT_CTRL: return cbor_serialize_float_ctrl(item, buffer, buffer_size); + default: + _CBOR_UNREACHABLE; + return 0; } } @@ -58,8 +60,7 @@ size_t _cbor_encoded_header_size(uint64_t size) { return 9; } -size_t cbor_serialized_size(const cbor_item_t *item) { - // cppcheck-suppress missingReturn +size_t cbor_serialized_size(const cbor_item_t* item) { switch (cbor_typeof(item)) { case CBOR_TYPE_UINT: case CBOR_TYPE_NEGINT: @@ -73,6 +74,9 @@ size_t cbor_serialized_size(const cbor_item_t *item) { return 5; case CBOR_INT_64: return 9; + default: + _CBOR_UNREACHABLE; + return 0; } // Note: We do not _cbor_safe_signaling_add zero-length definite strings, // they would cause zeroes to propagate. All other items are at least one @@ -86,7 +90,7 @@ size_t cbor_serialized_size(const cbor_item_t *item) { cbor_bytestring_length(item)); } size_t indef_bytestring_size = 2; // Leading byte + break - cbor_item_t **chunks = cbor_bytestring_chunks_handle(item); + cbor_item_t** chunks = cbor_bytestring_chunks_handle(item); for (size_t i = 0; i < cbor_bytestring_chunk_count(item); i++) { indef_bytestring_size = _cbor_safe_signaling_add( indef_bytestring_size, cbor_serialized_size(chunks[i])); @@ -101,7 +105,7 @@ size_t cbor_serialized_size(const cbor_item_t *item) { return _cbor_safe_signaling_add(header_size, cbor_string_length(item)); } size_t indef_string_size = 2; // Leading byte + break - cbor_item_t **chunks = cbor_string_chunks_handle(item); + cbor_item_t** chunks = cbor_string_chunks_handle(item); for (size_t i = 0; i < cbor_string_chunk_count(item); i++) { indef_string_size = _cbor_safe_signaling_add( indef_string_size, cbor_serialized_size(chunks[i])); @@ -112,7 +116,7 @@ size_t cbor_serialized_size(const cbor_item_t *item) { size_t array_size = cbor_array_is_definite(item) ? _cbor_encoded_header_size(cbor_array_size(item)) : 2; // Leading byte + break - cbor_item_t **items = cbor_array_handle(item); + cbor_item_t** items = cbor_array_handle(item); for (size_t i = 0; i < cbor_array_size(item); i++) { array_size = _cbor_safe_signaling_add(array_size, cbor_serialized_size(items[i])); @@ -123,7 +127,7 @@ size_t cbor_serialized_size(const cbor_item_t *item) { size_t map_size = cbor_map_is_definite(item) ? _cbor_encoded_header_size(cbor_map_size(item)) : 2; // Leading byte + break - struct cbor_pair *items = cbor_map_handle(item); + struct cbor_pair* items = cbor_map_handle(item); for (size_t i = 0; i < cbor_map_size(item); i++) { map_size = _cbor_safe_signaling_add( map_size, @@ -147,12 +151,18 @@ size_t cbor_serialized_size(const cbor_item_t *item) { return 5; case CBOR_FLOAT_64: return 9; + default: + _CBOR_UNREACHABLE; + return 0; } + default: + _CBOR_UNREACHABLE; + return 0; } } -size_t cbor_serialize_alloc(const cbor_item_t *item, unsigned char **buffer, - size_t *buffer_size) { +size_t cbor_serialize_alloc(const cbor_item_t* item, unsigned char** buffer, + size_t* buffer_size) { *buffer = NULL; size_t serialized_size = cbor_serialized_size(item); if (serialized_size == 0) { @@ -171,7 +181,7 @@ size_t cbor_serialize_alloc(const cbor_item_t *item, unsigned char **buffer, return written; } -size_t cbor_serialize_uint(const cbor_item_t *item, unsigned char *buffer, +size_t cbor_serialize_uint(const cbor_item_t* item, unsigned char* buffer, size_t buffer_size) { CBOR_ASSERT(cbor_isa_uint(item)); // cppcheck-suppress missingReturn @@ -184,10 +194,13 @@ size_t cbor_serialize_uint(const cbor_item_t *item, unsigned char *buffer, return cbor_encode_uint32(cbor_get_uint32(item), buffer, buffer_size); case CBOR_INT_64: return cbor_encode_uint64(cbor_get_uint64(item), buffer, buffer_size); + default: + _CBOR_UNREACHABLE; + return 0; } } -size_t cbor_serialize_negint(const cbor_item_t *item, unsigned char *buffer, +size_t cbor_serialize_negint(const cbor_item_t* item, unsigned char* buffer, size_t buffer_size) { CBOR_ASSERT(cbor_isa_negint(item)); // cppcheck-suppress missingReturn @@ -200,10 +213,13 @@ size_t cbor_serialize_negint(const cbor_item_t *item, unsigned char *buffer, return cbor_encode_negint32(cbor_get_uint32(item), buffer, buffer_size); case CBOR_INT_64: return cbor_encode_negint64(cbor_get_uint64(item), buffer, buffer_size); + default: + _CBOR_UNREACHABLE; + return 0; } } -size_t cbor_serialize_bytestring(const cbor_item_t *item, unsigned char *buffer, +size_t cbor_serialize_bytestring(const cbor_item_t* item, unsigned char* buffer, size_t buffer_size) { CBOR_ASSERT(cbor_isa_bytestring(item)); if (cbor_bytestring_is_definite(item)) { @@ -220,7 +236,7 @@ size_t cbor_serialize_bytestring(const cbor_item_t *item, unsigned char *buffer, size_t written = cbor_encode_indef_bytestring_start(buffer, buffer_size); if (written == 0) return 0; - cbor_item_t **chunks = cbor_bytestring_chunks_handle(item); + cbor_item_t** chunks = cbor_bytestring_chunks_handle(item); for (size_t i = 0; i < chunk_count; i++) { size_t chunk_written = cbor_serialize_bytestring( chunks[i], buffer + written, buffer_size - written); @@ -235,7 +251,7 @@ size_t cbor_serialize_bytestring(const cbor_item_t *item, unsigned char *buffer, } } -size_t cbor_serialize_string(const cbor_item_t *item, unsigned char *buffer, +size_t cbor_serialize_string(const cbor_item_t* item, unsigned char* buffer, size_t buffer_size) { CBOR_ASSERT(cbor_isa_string(item)); if (cbor_string_is_definite(item)) { @@ -252,7 +268,7 @@ size_t cbor_serialize_string(const cbor_item_t *item, unsigned char *buffer, size_t written = cbor_encode_indef_string_start(buffer, buffer_size); if (written == 0) return 0; - cbor_item_t **chunks = cbor_string_chunks_handle(item); + cbor_item_t** chunks = cbor_string_chunks_handle(item); for (size_t i = 0; i < chunk_count; i++) { size_t chunk_written = cbor_serialize_string(chunks[i], buffer + written, buffer_size - written); @@ -267,11 +283,11 @@ size_t cbor_serialize_string(const cbor_item_t *item, unsigned char *buffer, } } -size_t cbor_serialize_array(const cbor_item_t *item, unsigned char *buffer, +size_t cbor_serialize_array(const cbor_item_t* item, unsigned char* buffer, size_t buffer_size) { CBOR_ASSERT(cbor_isa_array(item)); size_t size = cbor_array_size(item), written = 0; - cbor_item_t **handle = cbor_array_handle(item); + cbor_item_t** handle = cbor_array_handle(item); if (cbor_array_is_definite(item)) { written = cbor_encode_array_start(size, buffer, buffer_size); } else { @@ -298,11 +314,11 @@ size_t cbor_serialize_array(const cbor_item_t *item, unsigned char *buffer, } } -size_t cbor_serialize_map(const cbor_item_t *item, unsigned char *buffer, +size_t cbor_serialize_map(const cbor_item_t* item, unsigned char* buffer, size_t buffer_size) { CBOR_ASSERT(cbor_isa_map(item)); size_t size = cbor_map_size(item), written = 0; - struct cbor_pair *handle = cbor_map_handle(item); + struct cbor_pair* handle = cbor_map_handle(item); if (cbor_map_is_definite(item)) { written = cbor_encode_map_start(size, buffer, buffer_size); @@ -336,7 +352,7 @@ size_t cbor_serialize_map(const cbor_item_t *item, unsigned char *buffer, } } -size_t cbor_serialize_tag(const cbor_item_t *item, unsigned char *buffer, +size_t cbor_serialize_tag(const cbor_item_t* item, unsigned char* buffer, size_t buffer_size) { CBOR_ASSERT(cbor_isa_tag(item)); size_t written = cbor_encode_tag(cbor_tag_value(item), buffer, buffer_size); @@ -348,7 +364,7 @@ size_t cbor_serialize_tag(const cbor_item_t *item, unsigned char *buffer, return written + item_written; } -size_t cbor_serialize_float_ctrl(const cbor_item_t *item, unsigned char *buffer, +size_t cbor_serialize_float_ctrl(const cbor_item_t* item, unsigned char* buffer, size_t buffer_size) { CBOR_ASSERT(cbor_isa_float_ctrl(item)); // cppcheck-suppress missingReturn @@ -364,5 +380,8 @@ size_t cbor_serialize_float_ctrl(const cbor_item_t *item, unsigned char *buffer, case CBOR_FLOAT_64: return cbor_encode_double(cbor_float_get_float8(item), buffer, buffer_size); + default: + _CBOR_UNREACHABLE; + return 0; } } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/serialization.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/serialization.h index 228ae75d601..10f5784a5b2 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/serialization.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/serialization.h @@ -28,7 +28,7 @@ extern "C" { * @param buffer_size Size of the \p buffer * @return Length of the result. 0 on failure. */ -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize(const cbor_item_t *item, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize(const cbor_item_t* item, cbor_mutable_data buffer, size_t buffer_size); @@ -42,7 +42,7 @@ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize(const cbor_item_t *item, * `size_t`. */ _CBOR_NODISCARD CBOR_EXPORT size_t -cbor_serialized_size(const cbor_item_t *item); +cbor_serialized_size(const cbor_item_t* item); /** Serialize the given item, allocating buffers as needed * @@ -62,9 +62,9 @@ cbor_serialized_size(const cbor_item_t *item); * @return Length of the result in bytes * @return 0 on memory allocation failure, in which case \p buffer is `NULL`. */ -CBOR_EXPORT size_t cbor_serialize_alloc(const cbor_item_t *item, - unsigned char **buffer, - size_t *buffer_size); +CBOR_EXPORT size_t cbor_serialize_alloc(const cbor_item_t* item, + unsigned char** buffer, + size_t* buffer_size); /** Serialize an uint * @@ -74,7 +74,7 @@ CBOR_EXPORT size_t cbor_serialize_alloc(const cbor_item_t *item, * @return Length of the result * @return 0 if the \p buffer_size doesn't fit the result */ -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_uint(const cbor_item_t *item, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_uint(const cbor_item_t* item, cbor_mutable_data buffer, size_t buffer_size); @@ -87,7 +87,7 @@ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_uint(const cbor_item_t *item, * @return 0 if the \p buffer_size doesn't fit the result */ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_negint( - const cbor_item_t *item, cbor_mutable_data buffer, size_t buffer_size); + const cbor_item_t* item, cbor_mutable_data buffer, size_t buffer_size); /** Serialize a bytestring * @@ -99,7 +99,7 @@ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_negint( * still be modified */ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_bytestring( - const cbor_item_t *item, cbor_mutable_data buffer, size_t buffer_size); + const cbor_item_t* item, cbor_mutable_data buffer, size_t buffer_size); /** Serialize a string * @@ -111,7 +111,7 @@ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_bytestring( * still be modified */ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_string( - const cbor_item_t *item, cbor_mutable_data buffer, size_t buffer_size); + const cbor_item_t* item, cbor_mutable_data buffer, size_t buffer_size); /** Serialize an array * * @param item An array @@ -122,7 +122,7 @@ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_string( * still be modified */ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_array( - const cbor_item_t *item, cbor_mutable_data buffer, size_t buffer_size); + const cbor_item_t* item, cbor_mutable_data buffer, size_t buffer_size); /** Serialize a map * @@ -133,7 +133,7 @@ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_array( * @return 0 if the \p buffer_size doesn't fit the result. The \p buffer may * still be modified */ -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_map(const cbor_item_t *item, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_map(const cbor_item_t* item, cbor_mutable_data buffer, size_t buffer_size); @@ -146,7 +146,7 @@ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_map(const cbor_item_t *item, * @return 0 if the \p buffer_size doesn't fit the result. The \p buffer may * still be modified */ -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_tag(const cbor_item_t *item, +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_tag(const cbor_item_t* item, cbor_mutable_data buffer, size_t buffer_size); @@ -159,7 +159,7 @@ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_tag(const cbor_item_t *item, * @return 0 if the \p buffer_size doesn't fit the result */ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_serialize_float_ctrl( - const cbor_item_t *item, cbor_mutable_data buffer, size_t buffer_size); + const cbor_item_t* item, cbor_mutable_data buffer, size_t buffer_size); #ifdef __cplusplus } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/streaming.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/streaming.c index 4b37701143a..595c85805f1 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/streaming.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/streaming.c @@ -9,7 +9,7 @@ #include "internal/loaders.h" static bool claim_bytes(size_t required, size_t provided, - struct cbor_decoder_result *result) { + struct cbor_decoder_result* result) { if (required > (provided - result->read)) { result->required = required + result->read; result->read = 0; @@ -42,7 +42,7 @@ static bool claim_bytes(size_t required, size_t provided, struct cbor_decoder_result cbor_stream_decode( cbor_data source, size_t source_size, - const struct cbor_callbacks *callbacks, void *context) { + const struct cbor_callbacks* callbacks, void* context) { // Attempt to claim the initial MTB byte struct cbor_decoder_result result = {.status = CBOR_DECODER_FINISHED}; if (!claim_bytes(1, source_size, &result)) { @@ -592,9 +592,10 @@ struct cbor_decoder_result cbor_stream_decode( case 0xFF: /* Break */ callbacks->indef_break(context); - // Never happens, the switch statement is exhaustive on the 1B range; make - // compiler happy + return result; default: + // Never happens, the switch statement is exhaustive on the 1B range + _CBOR_UNREACHABLE; return result; } } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/strings.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/strings.c index 6ae96545cfe..4ef4fa3c9b7 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/strings.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/strings.c @@ -10,18 +10,20 @@ #include "internal/memory_utils.h" #include "internal/unicode.h" -cbor_item_t *cbor_new_definite_string(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t)); +cbor_item_t* cbor_new_definite_string(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t)); _CBOR_NOTNULL(item); *item = (cbor_item_t){ .refcount = 1, .type = CBOR_TYPE_STRING, - .metadata = {.string_metadata = {_CBOR_METADATA_DEFINITE, 0}}}; + .metadata = {.string_metadata = {.type = _CBOR_METADATA_DEFINITE, + .codepoint_count = 0, + .length = 0}}}; return item; } -cbor_item_t *cbor_new_indefinite_string(void) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t)); +cbor_item_t* cbor_new_indefinite_string(void) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t)); _CBOR_NOTNULL(item); *item = (cbor_item_t){ .refcount = 1, @@ -30,7 +32,7 @@ cbor_item_t *cbor_new_indefinite_string(void) { .length = 0}}, .data = _cbor_malloc(sizeof(struct cbor_indefinite_string_data))}; _CBOR_DEPENDENT_NOTNULL(item, item->data); - *((struct cbor_indefinite_string_data *)item->data) = + *((struct cbor_indefinite_string_data*)item->data) = (struct cbor_indefinite_string_data){ .chunk_count = 0, .chunk_capacity = 0, @@ -39,28 +41,28 @@ cbor_item_t *cbor_new_indefinite_string(void) { return item; } -cbor_item_t *cbor_build_string(const char *val) { - cbor_item_t *item = cbor_new_definite_string(); +cbor_item_t* cbor_build_string(const char* val) { + cbor_item_t* item = cbor_new_definite_string(); _CBOR_NOTNULL(item); size_t len = strlen(val); - unsigned char *handle = _cbor_malloc(len); + unsigned char* handle = _cbor_malloc(len); _CBOR_DEPENDENT_NOTNULL(item, handle); memcpy(handle, val, len); cbor_string_set_handle(item, handle, len); return item; } -cbor_item_t *cbor_build_stringn(const char *val, size_t length) { - cbor_item_t *item = cbor_new_definite_string(); +cbor_item_t* cbor_build_stringn(const char* val, size_t length) { + cbor_item_t* item = cbor_new_definite_string(); _CBOR_NOTNULL(item); - unsigned char *handle = _cbor_malloc(length); + unsigned char* handle = _cbor_malloc(length); _CBOR_DEPENDENT_NOTNULL(item, handle); memcpy(handle, val, length); cbor_string_set_handle(item, handle, length); return item; } -void cbor_string_set_handle(cbor_item_t *item, +void cbor_string_set_handle(cbor_item_t* item, cbor_mutable_data CBOR_RESTRICT_POINTER data, size_t length) { CBOR_ASSERT(cbor_isa_string(item)); @@ -78,23 +80,23 @@ void cbor_string_set_handle(cbor_item_t *item, } } -cbor_item_t **cbor_string_chunks_handle(const cbor_item_t *item) { +cbor_item_t** cbor_string_chunks_handle(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_string(item)); CBOR_ASSERT(cbor_string_is_indefinite(item)); - return ((struct cbor_indefinite_string_data *)item->data)->chunks; + return ((struct cbor_indefinite_string_data*)item->data)->chunks; } -size_t cbor_string_chunk_count(const cbor_item_t *item) { +size_t cbor_string_chunk_count(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_string(item)); CBOR_ASSERT(cbor_string_is_indefinite(item)); - return ((struct cbor_indefinite_string_data *)item->data)->chunk_count; + return ((struct cbor_indefinite_string_data*)item->data)->chunk_count; } -bool cbor_string_add_chunk(cbor_item_t *item, cbor_item_t *chunk) { +bool cbor_string_add_chunk(cbor_item_t* item, cbor_item_t* chunk) { CBOR_ASSERT(cbor_isa_string(item)); CBOR_ASSERT(cbor_string_is_indefinite(item)); - struct cbor_indefinite_string_data *data = - (struct cbor_indefinite_string_data *)item->data; + struct cbor_indefinite_string_data* data = + (struct cbor_indefinite_string_data*)item->data; if (data->chunk_count == data->chunk_capacity) { if (!_cbor_safe_to_multiply(CBOR_BUFFER_GROWTH, data->chunk_capacity)) { return false; @@ -103,8 +105,8 @@ bool cbor_string_add_chunk(cbor_item_t *item, cbor_item_t *chunk) { size_t new_chunk_capacity = data->chunk_capacity == 0 ? 1 : CBOR_BUFFER_GROWTH * (data->chunk_capacity); - cbor_item_t **new_chunks_data = _cbor_realloc_multiple( - data->chunks, sizeof(cbor_item_t *), new_chunk_capacity); + cbor_item_t** new_chunks_data = _cbor_realloc_multiple( + data->chunks, sizeof(cbor_item_t*), new_chunk_capacity); if (new_chunks_data == NULL) { return false; @@ -117,26 +119,26 @@ bool cbor_string_add_chunk(cbor_item_t *item, cbor_item_t *chunk) { return true; } -size_t cbor_string_length(const cbor_item_t *item) { +size_t cbor_string_length(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_string(item)); return item->metadata.string_metadata.length; } -unsigned char *cbor_string_handle(const cbor_item_t *item) { +unsigned char* cbor_string_handle(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_string(item)); return item->data; } -size_t cbor_string_codepoint_count(const cbor_item_t *item) { +size_t cbor_string_codepoint_count(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_string(item)); return item->metadata.string_metadata.codepoint_count; } -bool cbor_string_is_definite(const cbor_item_t *item) { +bool cbor_string_is_definite(const cbor_item_t* item) { CBOR_ASSERT(cbor_isa_string(item)); return item->metadata.string_metadata.type == _CBOR_METADATA_DEFINITE; } -bool cbor_string_is_indefinite(const cbor_item_t *item) { +bool cbor_string_is_indefinite(const cbor_item_t* item) { return !cbor_string_is_definite(item); } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/strings.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/strings.h index 3e03f81385f..a21133b3012 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/strings.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/strings.h @@ -29,7 +29,7 @@ extern "C" { * @param item a definite string * @return length of the string. Zero if no chunk has been attached yet */ -_CBOR_NODISCARD CBOR_EXPORT size_t cbor_string_length(const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT size_t cbor_string_length(const cbor_item_t* item); /** The number of codepoints in this string * @@ -40,7 +40,7 @@ _CBOR_NODISCARD CBOR_EXPORT size_t cbor_string_length(const cbor_item_t *item); * @return The number of codepoints in this string */ _CBOR_NODISCARD CBOR_EXPORT size_t -cbor_string_codepoint_count(const cbor_item_t *item); +cbor_string_codepoint_count(const cbor_item_t* item); /** Is the string definite? * @@ -48,7 +48,7 @@ cbor_string_codepoint_count(const cbor_item_t *item); * @return Is the string definite? */ _CBOR_NODISCARD CBOR_EXPORT bool cbor_string_is_definite( - const cbor_item_t *item); + const cbor_item_t* item); /** Is the string indefinite? * @@ -56,7 +56,7 @@ _CBOR_NODISCARD CBOR_EXPORT bool cbor_string_is_definite( * @return Is the string indefinite? */ _CBOR_NODISCARD CBOR_EXPORT bool cbor_string_is_indefinite( - const cbor_item_t *item); + const cbor_item_t* item); /** Get the handle to the underlying string * @@ -68,7 +68,7 @@ _CBOR_NODISCARD CBOR_EXPORT bool cbor_string_is_indefinite( * @return `NULL` if no data have been assigned yet. */ _CBOR_NODISCARD CBOR_EXPORT cbor_mutable_data -cbor_string_handle(const cbor_item_t *item); +cbor_string_handle(const cbor_item_t* item); /** Set the handle to the underlying string * @@ -87,7 +87,7 @@ cbor_string_handle(const cbor_item_t *item); * @param length Length of the data block */ CBOR_EXPORT void cbor_string_set_handle( - cbor_item_t *item, cbor_mutable_data CBOR_RESTRICT_POINTER data, + cbor_item_t* item, cbor_mutable_data CBOR_RESTRICT_POINTER data, size_t length); /** Get the handle to the array of chunks @@ -98,8 +98,8 @@ CBOR_EXPORT void cbor_string_set_handle( * @param item A indefinite string * @return array of #cbor_string_chunk_count definite strings */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t **cbor_string_chunks_handle( - const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t** cbor_string_chunks_handle( + const cbor_item_t* item); /** Get the number of chunks this string consist of * @@ -107,7 +107,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t **cbor_string_chunks_handle( * @return The chunk count. 0 for freshly created items. */ _CBOR_NODISCARD CBOR_EXPORT size_t -cbor_string_chunk_count(const cbor_item_t *item); +cbor_string_chunk_count(const cbor_item_t* item); /** Appends a chunk to the string * @@ -122,8 +122,8 @@ cbor_string_chunk_count(const cbor_item_t *item); * case, the refcount of @p `chunk` is not increased and the @p `item` is left * intact. */ -_CBOR_NODISCARD CBOR_EXPORT bool cbor_string_add_chunk(cbor_item_t *item, - cbor_item_t *chunk); +_CBOR_NODISCARD CBOR_EXPORT bool cbor_string_add_chunk(cbor_item_t* item, + cbor_item_t* chunk); /** Creates a new definite string * @@ -133,7 +133,7 @@ _CBOR_NODISCARD CBOR_EXPORT bool cbor_string_add_chunk(cbor_item_t *item, * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_definite_string(void); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_definite_string(void); /** Creates a new indefinite string * @@ -143,7 +143,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_definite_string(void); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_indefinite_string(void); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_indefinite_string(void); /** Creates a new string and initializes it * @@ -158,7 +158,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_indefinite_string(void); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_string(const char *val); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_string(const char* val); /** Creates a new string and initializes it * @@ -173,7 +173,7 @@ _CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_string(const char *val); * initialized to one. * @return `NULL` if memory allocation fails */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_stringn(const char *val, +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_stringn(const char* val, size_t length); #ifdef __cplusplus diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/tags.c b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/tags.c index 3f3edb0b0e1..343a1cda560 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/tags.c +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/tags.c @@ -7,8 +7,8 @@ #include "tags.h" -cbor_item_t *cbor_new_tag(uint64_t value) { - cbor_item_t *item = _cbor_malloc(sizeof(cbor_item_t)); +cbor_item_t* cbor_new_tag(uint64_t value) { + cbor_item_t* item = _cbor_malloc(sizeof(cbor_item_t)); _CBOR_NOTNULL(item); *item = (cbor_item_t){ @@ -20,24 +20,24 @@ cbor_item_t *cbor_new_tag(uint64_t value) { return item; } -cbor_item_t *cbor_tag_item(const cbor_item_t *item) { - CBOR_ASSERT(cbor_isa_tag(item)); - return cbor_incref(item->metadata.tag_metadata.tagged_item); +cbor_item_t* cbor_tag_item(const cbor_item_t* tag) { + CBOR_ASSERT(cbor_isa_tag(tag)); + return cbor_incref(tag->metadata.tag_metadata.tagged_item); } -uint64_t cbor_tag_value(const cbor_item_t *item) { - CBOR_ASSERT(cbor_isa_tag(item)); - return item->metadata.tag_metadata.value; +uint64_t cbor_tag_value(const cbor_item_t* tag) { + CBOR_ASSERT(cbor_isa_tag(tag)); + return tag->metadata.tag_metadata.value; } -void cbor_tag_set_item(cbor_item_t *item, cbor_item_t *tagged_item) { - CBOR_ASSERT(cbor_isa_tag(item)); +void cbor_tag_set_item(cbor_item_t* tag, cbor_item_t* tagged_item) { + CBOR_ASSERT(cbor_isa_tag(tag)); cbor_incref(tagged_item); - item->metadata.tag_metadata.tagged_item = tagged_item; + tag->metadata.tag_metadata.tagged_item = tagged_item; } -cbor_item_t *cbor_build_tag(uint64_t value, cbor_item_t *item) { - cbor_item_t *res = cbor_new_tag(value); +cbor_item_t* cbor_build_tag(uint64_t value, cbor_item_t* item) { + cbor_item_t* res = cbor_new_tag(value); if (res == NULL) { return NULL; } diff --git a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/tags.h b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/tags.h index a7365df1020..360cc861a53 100644 --- a/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/tags.h +++ b/contrib/restricted/aws/aws-c-common/source/external/libcbor/cbor/tags.h @@ -21,51 +21,55 @@ extern "C" { * ============================================================================ */ -/** Create a new tag +/** Create a new tag. * - * @param value The tag value. Please consult the tag repository - * @return Reference to the new tag item. The item's reference count is - * initialized to one. - * @return `NULL` if memory allocation fails + * @param value The tag value (number). + * @return Reference to the new tag. Its reference count is initialized to one + * and it points to a `NULL` item. + * @return `NULL` if memory allocation fails. */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_tag(uint64_t value); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_new_tag(uint64_t value); -/** Get the tagged item +/** Get the tagged item (what the tag points to). * - * @param item A tag - * @return Reference to the tagged item + * @param tag A #CBOR_TYPE_TAG tag. + * @return Reference to the tagged item. * * Increases the reference count of the underlying item. The returned reference * must be released using #cbor_decref. */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_tag_item(const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_tag_item(const cbor_item_t* tag); -/** Get tag value +/** Get the tag value. * - * @param item A tag - * @return The tag value. Please consult the tag repository + * @param tag A #CBOR_TYPE_TAG tag. + * @return The tag value (number). */ -_CBOR_NODISCARD CBOR_EXPORT uint64_t cbor_tag_value(const cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT uint64_t cbor_tag_value(const cbor_item_t* tag); -/** Set the tagged item +/** Assign a tag to an item. * - * @param item A tag + * @param tag A #CBOR_TYPE_TAG tag. * @param tagged_item The item to tag. Its reference count will be increased * by one. + * + * If the tag already points to an item, the pointer will be replaced, without a + * reference count change on the previous item. + * TODO: Should we release the reference automatically? */ -CBOR_EXPORT void cbor_tag_set_item(cbor_item_t *item, cbor_item_t *tagged_item); +CBOR_EXPORT void cbor_tag_set_item(cbor_item_t* tag, cbor_item_t* tagged_item); -/** Build a new tag +/** Build a new tag. * * @param item The item to tag. Its reference count will be increased by * one. - * @param value Tag value + * @param value The tag value (number). * @return Reference to the new tag item. The item's reference count is * initialized to one. - * @return `NULL` if memory allocation fails + * @return `NULL` if memory allocation fails. */ -_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_tag(uint64_t value, - cbor_item_t *item); +_CBOR_NODISCARD CBOR_EXPORT cbor_item_t* cbor_build_tag(uint64_t value, + cbor_item_t* item); #ifdef __cplusplus } diff --git a/contrib/restricted/aws/aws-c-common/source/uuid.c b/contrib/restricted/aws/aws-c-common/source/uuid.c index f880c0d95dd..f94f7d0dd1a 100644 --- a/contrib/restricted/aws/aws-c-common/source/uuid.c +++ b/contrib/restricted/aws/aws-c-common/source/uuid.c @@ -17,6 +17,10 @@ "-" HEX_CHAR_FMT HEX_CHAR_FMT "-" HEX_CHAR_FMT HEX_CHAR_FMT "-" HEX_CHAR_FMT HEX_CHAR_FMT \ "-" HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT +#define UUID_FORMAT_COMPACT \ + HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT \ + HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT HEX_CHAR_FMT + #include <stdio.h> #ifdef _MSC_VER @@ -66,14 +70,18 @@ int aws_uuid_init_from_str(struct aws_uuid *uuid, const struct aws_byte_cursor * return AWS_OP_SUCCESS; } -int aws_uuid_to_str(const struct aws_uuid *uuid, struct aws_byte_buf *output) { +static int s_uuid_to_str( + const struct aws_uuid *uuid, + struct aws_byte_buf *output, + const char *format_string, + size_t padded_formatted_length) { size_t space_remaining = output->capacity - output->len; - AWS_ERROR_PRECONDITION(space_remaining >= AWS_UUID_STR_LEN, AWS_ERROR_SHORT_BUFFER); + AWS_ERROR_PRECONDITION(space_remaining >= padded_formatted_length, AWS_ERROR_SHORT_BUFFER); snprintf( (char *)(output->buffer + output->len), space_remaining, - UUID_FORMAT, + format_string, uuid->uuid_data[0], uuid->uuid_data[1], uuid->uuid_data[2], @@ -91,11 +99,19 @@ int aws_uuid_to_str(const struct aws_uuid *uuid, struct aws_byte_buf *output) { uuid->uuid_data[14], uuid->uuid_data[15]); - output->len += AWS_UUID_STR_LEN - 1; + output->len += padded_formatted_length - 1; return AWS_OP_SUCCESS; } +int aws_uuid_to_str(const struct aws_uuid *uuid, struct aws_byte_buf *output) { + return s_uuid_to_str(uuid, output, UUID_FORMAT, AWS_UUID_STR_LEN); +} + +int aws_uuid_to_str_compact(const struct aws_uuid *uuid, struct aws_byte_buf *output) { + return s_uuid_to_str(uuid, output, UUID_FORMAT_COMPACT, AWS_UUID_STR_COMPACT_LEN); +} + bool aws_uuid_equals(const struct aws_uuid *a, const struct aws_uuid *b) { return 0 == memcmp(a->uuid_data, b->uuid_data, sizeof(a->uuid_data)); } diff --git a/contrib/restricted/aws/aws-c-common/ya.make b/contrib/restricted/aws/aws-c-common/ya.make index 7705eaa56e4..262ec0bae73 100644 --- a/contrib/restricted/aws/aws-c-common/ya.make +++ b/contrib/restricted/aws/aws-c-common/ya.make @@ -12,9 +12,9 @@ LICENSE( LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -VERSION(0.12.3) +VERSION(0.12.4) -ORIGINAL_SOURCE(https://github.com/awslabs/aws-c-common/archive/v0.12.3.tar.gz) +ORIGINAL_SOURCE(https://github.com/awslabs/aws-c-common/archive/v0.12.4.tar.gz) ADDINCL( GLOBAL contrib/restricted/aws/aws-c-common/generated/include |