Fix: usage of `bt_value_array_get_length()`
[babeltrace.git] / src / lib / trace-ir / attributes.c
index 488dd86feab50bb4449d400797c7c255ef9d5555..4512880a5c6ec903f26e3f5af669a677a85dc653 100644 (file)
@@ -77,9 +77,9 @@ void bt_attributes_destroy(struct bt_value *attr_obj)
 }
 
 BT_HIDDEN
-int64_t bt_attributes_get_count(const struct bt_value *attr_obj)
+uint64_t bt_attributes_get_count(const struct bt_value *attr_obj)
 {
-       return bt_value_array_get_size(attr_obj);
+       return bt_value_array_get_length(attr_obj);
 }
 
 BT_HIDDEN
@@ -90,8 +90,8 @@ const char *bt_attributes_get_field_name(const struct bt_value *attr_obj,
        const struct bt_value *attr_field_obj = NULL;
        const struct bt_value *attr_field_name_obj = NULL;
 
-       BT_ASSERT(attr_obj);
-       BT_ASSERT(index < bt_value_array_get_size(attr_obj));
+       BT_ASSERT_DBG(attr_obj);
+       BT_ASSERT_DBG(index < bt_value_array_get_length(attr_obj));
        attr_field_obj = bt_value_array_borrow_element_by_index_const(
                attr_obj, index);
        if (!attr_field_obj) {
@@ -125,8 +125,8 @@ struct bt_value *bt_attributes_borrow_field_value(
        struct bt_value *value_obj = NULL;
        struct bt_value *attr_field_obj = NULL;
 
-       BT_ASSERT(attr_obj);
-       BT_ASSERT(index < bt_value_array_get_size(attr_obj));
+       BT_ASSERT_DBG(attr_obj);
+       BT_ASSERT_DBG(index < bt_value_array_get_length(attr_obj));
        attr_field_obj =
                bt_value_array_borrow_element_by_index(attr_obj, index);
        if (!attr_field_obj) {
@@ -153,19 +153,11 @@ static
 struct bt_value *bt_attributes_borrow_field_by_name(
                struct bt_value *attr_obj, const char *name)
 {
-       uint64_t i;
-       int64_t attr_size;
+       uint64_t i, attr_size;
        struct bt_value *value_obj = NULL;
        struct bt_value *attr_field_name_obj = NULL;
 
-       attr_size = bt_value_array_get_size(attr_obj);
-       if (attr_size < 0) {
-               BT_LIB_LOGE_APPEND_CAUSE(
-                       "Cannot get array value's size: %![value-]+v",
-                       attr_obj);
-               goto error;
-       }
-
+       attr_size = bt_value_array_get_length(attr_obj);
        for (i = 0; i < attr_size; ++i) {
                const char *field_name;
 
@@ -263,8 +255,8 @@ struct bt_value *bt_attributes_borrow_field_value_by_name(
        struct bt_value *value_obj = NULL;
        struct bt_value *attr_field_obj = NULL;
 
-       BT_ASSERT(attr_obj);
-       BT_ASSERT(name);
+       BT_ASSERT_DBG(attr_obj);
+       BT_ASSERT_DBG(name);
        attr_field_obj = bt_attributes_borrow_field_by_name(attr_obj, name);
        if (!attr_field_obj) {
                BT_LOGD("Cannot find attributes object's field by name: "
@@ -288,14 +280,13 @@ end:
 BT_HIDDEN
 int bt_attributes_freeze(const struct bt_value *attr_obj)
 {
-       uint64_t i;
-       int64_t count;
+       uint64_t i, count;
        int ret = 0;
 
        BT_ASSERT(attr_obj);
        BT_LOGD("Freezing attributes object: value-addr=%p", attr_obj);
-       count = bt_value_array_get_size(attr_obj);
-       BT_ASSERT(count >= 0);
+
+       count = bt_value_array_get_length(attr_obj);
 
        /*
         * We do not freeze the array value object itself here, since
This page took 0.028931 seconds and 4 git commands to generate.