Skip to content

Commit

Permalink
lib: cmetrics: upgrade to v0.6.5 (#8176)
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Silva <[email protected]>
  • Loading branch information
edsiper authored Nov 19, 2023
1 parent 9b9c800 commit 3746b4c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/cmetrics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# CMetrics Version
set(CMT_VERSION_MAJOR 0)
set(CMT_VERSION_MINOR 6)
set(CMT_VERSION_PATCH 4)
set(CMT_VERSION_PATCH 5)
set(CMT_VERSION_STR "${CMT_VERSION_MAJOR}.${CMT_VERSION_MINOR}.${CMT_VERSION_PATCH}")

# Include helpers
Expand Down
21 changes: 19 additions & 2 deletions lib/cmetrics/include/cmetrics/cmt_variant_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@

#include <mpack/mpack.h>

#define CFL_VARIANT_UTILS_MAXIMUM_FIXED_ARRAY_SIZE 100
#define CFL_VARIANT_UTILS_INITIAL_ARRAY_SIZE 100
#define CFL_VARIANT_UTILS_SERIALIZED_ARRAY_SIZE_LIMIT 100000

/* These are the only functions meant for general use,
* the reason why the kvlist packing and unpacking
* functions are exposed is the internal and external
Expand Down Expand Up @@ -226,12 +230,25 @@ static inline int unpack_cfl_array(mpack_reader_t *reader,

entry_count = mpack_tag_array_count(&tag);

internal_array = cfl_array_create(entry_count);
if (entry_count >= CFL_VARIANT_UTILS_SERIALIZED_ARRAY_SIZE_LIMIT) {
return -2;
}

if (entry_count >= CFL_VARIANT_UTILS_MAXIMUM_FIXED_ARRAY_SIZE) {
internal_array = cfl_array_create(CFL_VARIANT_UTILS_INITIAL_ARRAY_SIZE);
}
else {
internal_array = cfl_array_create(entry_count);
}

if (internal_array == NULL) {
return -3;
}

if (entry_count >= CFL_VARIANT_UTILS_MAXIMUM_FIXED_ARRAY_SIZE) {
cfl_array_resizable(internal_array, CFL_TRUE);
}

for (index = 0 ; index < entry_count ; index++) {
result = unpack_cfl_variant(reader, &entry_value);

Expand Down Expand Up @@ -595,7 +612,7 @@ static inline int unpack_cfl_variant(mpack_reader_t *reader,
if (value_type == mpack_type_str) {
result = unpack_cfl_variant_string(reader, value);
}
else if (value_type == mpack_type_str) {
else if (value_type == mpack_type_bool) {
result = unpack_cfl_variant_boolean(reader, value);
}
else if (value_type == mpack_type_int) {
Expand Down

0 comments on commit 3746b4c

Please sign in to comment.