Port: normalize path in test_plugin_bt2
[babeltrace.git] / lib / values.c
index 8c9429636eed8ae710cfd0cec582983f69f0199d..ea69643e4dff8d5dde51687e7d7885051957cec2 100644 (file)
  * SOFTWARE.
  */
 
+#define BT_LOG_TAG "VALUES"
+#include <babeltrace/lib-logging-internal.h>
+
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
 #include <string.h>
 #include <inttypes.h>
 #include <babeltrace/compiler-internal.h>
-#include <babeltrace/object-internal.h>
 #include <babeltrace/ref.h>
 #include <babeltrace/values.h>
 #include <babeltrace/compat/glib-internal.h>
-
-#define BT_LOG_TAG "VALUES"
-#include <babeltrace/lib-logging-internal.h>
+#include <babeltrace/types.h>
+#include <babeltrace/object-internal.h>
+#include <babeltrace/values-internal.h>
 
 #define BT_VALUE_FROM_CONCRETE(_concrete) ((struct bt_value *) (_concrete))
 #define BT_VALUE_TO_BOOL(_base) ((struct bt_value_bool *) (_base))
@@ -50,7 +52,7 @@
 struct bt_value {
        struct bt_object base;
        enum bt_value_type type;
-       bool is_frozen;
+       bt_bool is_frozen;
 };
 
 static
@@ -64,14 +66,14 @@ struct bt_value bt_value_null_instance = {
                .parent = NULL,
        },
        .type = BT_VALUE_TYPE_NULL,
-       .is_frozen = true,
+       .is_frozen = BT_TRUE,
 };
 
 struct bt_value *bt_value_null = &bt_value_null_instance;
 
 struct bt_value_bool {
        struct bt_value base;
-       bool value;
+       bt_bool value;
 };
 
 struct bt_value_integer {
@@ -194,17 +196,11 @@ struct bt_value *bt_value_array_copy(const struct bt_value *array_obj)
                struct bt_value *element_obj_copy;
                struct bt_value *element_obj = bt_value_array_get(array_obj, i);
 
-               if (!element_obj) {
-                       BT_LOGE("Cannot get array value's element: "
-                               "addr=%p, index=%d",
-                               array_obj, i);
-                       BT_PUT(copy_obj);
-                       goto end;
-               }
-
+               assert(element_obj);
+               BT_LOGD("Copying array value's element: element-addr=%p, "
+                       "index=%d", element_obj, i);
                element_obj_copy = bt_value_copy(element_obj);
                BT_PUT(element_obj);
-
                if (!element_obj_copy) {
                        BT_LOGE("Cannot copy array value's element: "
                                "array-addr=%p, index=%d",
@@ -215,7 +211,6 @@ struct bt_value *bt_value_array_copy(const struct bt_value *array_obj)
 
                ret = bt_value_array_append(copy_obj, element_obj_copy);
                BT_PUT(element_obj_copy);
-
                if (ret) {
                        BT_LOGE("Cannot append to array value: addr=%p",
                                array_obj);
@@ -224,7 +219,8 @@ struct bt_value *bt_value_array_copy(const struct bt_value *array_obj)
                }
        }
 
-       BT_LOGD("Copied array value: addr=%p", array_obj);
+       BT_LOGD("Copied array value: original-addr=%p, copy-addr=%p",
+               array_obj, copy_obj);
 
 end:
        return copy_obj;
@@ -253,8 +249,10 @@ struct bt_value *bt_value_map_copy(const struct bt_value *map_obj)
        while (g_hash_table_iter_next(&iter, &key, &element_obj)) {
                const char *key_str = g_quark_to_string(GPOINTER_TO_UINT(key));
 
+               assert(key_str);
+               BT_LOGD("Copying map value's element: element-addr=%p, "
+                       "key=\"%s\"", element_obj, key_str);
                element_obj_copy = bt_value_copy(element_obj);
-
                if (!element_obj_copy) {
                        BT_LOGE("Cannot copy map value's element: "
                                "map-addr=%p, key=\"%s\"",
@@ -265,7 +263,6 @@ struct bt_value *bt_value_map_copy(const struct bt_value *map_obj)
 
                ret = bt_value_map_insert(copy_obj, key_str, element_obj_copy);
                BT_PUT(element_obj_copy);
-
                if (ret) {
                        BT_LOGE("Cannot insert into map value: addr=%p, key=\"%s\"",
                                map_obj, key_str);
@@ -292,55 +289,87 @@ struct bt_value *(* const copy_funcs[])(const struct bt_value *) = {
 };
 
 static
-bool bt_value_null_compare(const struct bt_value *object_a,
+bt_bool bt_value_null_compare(const struct bt_value *object_a,
                const struct bt_value *object_b)
 {
        /*
-        * Always true since bt_value_compare() already checks if both
+        * Always BT_TRUE since bt_value_compare() already checks if both
         * object_a and object_b have the same type, and in the case of
         * null value objects, they're always the same if it is so.
         */
-       return true;
+       return BT_TRUE;
 }
 
 static
-bool bt_value_bool_compare(const struct bt_value *object_a,
+bt_bool bt_value_bool_compare(const struct bt_value *object_a,
                const struct bt_value *object_b)
 {
-       return BT_VALUE_TO_BOOL(object_a)->value ==
-               BT_VALUE_TO_BOOL(object_b)->value;
+       if (BT_VALUE_TO_BOOL(object_a)->value !=
+                       BT_VALUE_TO_BOOL(object_b)->value) {
+               BT_LOGV("Boolean value objects are different: "
+                       "bool-a-val=%d, bool-b-val=%d",
+                       BT_VALUE_TO_BOOL(object_a)->value,
+                       BT_VALUE_TO_BOOL(object_b)->value);
+               return BT_FALSE;
+       }
+
+       return BT_TRUE;
 }
 
 static
-bool bt_value_integer_compare(const struct bt_value *object_a,
+bt_bool bt_value_integer_compare(const struct bt_value *object_a,
                const struct bt_value *object_b)
 {
-       return BT_VALUE_TO_INTEGER(object_a)->value ==
-               BT_VALUE_TO_INTEGER(object_b)->value;
+       if (BT_VALUE_TO_INTEGER(object_a)->value !=
+                       BT_VALUE_TO_INTEGER(object_b)->value) {
+               BT_LOGV("Integer value objects are different: "
+                       "int-a-val=%" PRId64 ", int-b-val=%" PRId64,
+                       BT_VALUE_TO_INTEGER(object_a)->value,
+                       BT_VALUE_TO_INTEGER(object_b)->value);
+               return BT_FALSE;
+       }
+
+       return BT_TRUE;
 }
 
 static
-bool bt_value_float_compare(const struct bt_value *object_a,
+bt_bool bt_value_float_compare(const struct bt_value *object_a,
                const struct bt_value *object_b)
 {
-       return BT_VALUE_TO_FLOAT(object_a)->value ==
-               BT_VALUE_TO_FLOAT(object_b)->value;
+       if (BT_VALUE_TO_FLOAT(object_a)->value !=
+                       BT_VALUE_TO_FLOAT(object_b)->value) {
+               BT_LOGV("Floating point number value objects are different: "
+                       "float-a-val=%f, float-b-val=%f",
+                       BT_VALUE_TO_FLOAT(object_a)->value,
+                       BT_VALUE_TO_FLOAT(object_b)->value);
+               return BT_FALSE;
+       }
+
+       return BT_TRUE;
 }
 
 static
-bool bt_value_string_compare(const struct bt_value *object_a,
+bt_bool bt_value_string_compare(const struct bt_value *object_a,
                const struct bt_value *object_b)
 {
-       return !strcmp(BT_VALUE_TO_STRING(object_a)->gstr->str,
-               BT_VALUE_TO_STRING(object_b)->gstr->str);
+       if (strcmp(BT_VALUE_TO_STRING(object_a)->gstr->str,
+                       BT_VALUE_TO_STRING(object_b)->gstr->str) != 0) {
+               BT_LOGV("String value objects are different: "
+                       "string-a-val=\"%s\", string-b-val=\"%s\"",
+                       BT_VALUE_TO_STRING(object_a)->gstr->str,
+                       BT_VALUE_TO_STRING(object_b)->gstr->str);
+               return BT_FALSE;
+       }
+
+       return BT_TRUE;
 }
 
 static
-bool bt_value_array_compare(const struct bt_value *object_a,
+bt_bool bt_value_array_compare(const struct bt_value *object_a,
                const struct bt_value *object_b)
 {
        int i;
-       bool ret = true;
+       bt_bool ret = BT_TRUE;
        const struct bt_value_array *array_obj_a =
                BT_VALUE_TO_ARRAY(object_a);
 
@@ -351,7 +380,7 @@ bool bt_value_array_compare(const struct bt_value *object_a,
                        object_a, object_b,
                        bt_value_array_size(object_a),
                        bt_value_array_size(object_b));
-               ret = false;
+               ret = BT_FALSE;
                goto end;
        }
 
@@ -365,10 +394,10 @@ bool bt_value_array_compare(const struct bt_value *object_a,
                if (!bt_value_compare(element_obj_a, element_obj_b)) {
                        BT_LOGV("Array values's elements are different: "
                                "value-a-addr=%p, value-b-addr=%p, index=%d",
-                               element_obj_a, element_obj_b, index);
+                               element_obj_a, element_obj_b, i);
                        BT_PUT(element_obj_a);
                        BT_PUT(element_obj_b);
-                       ret = false;
+                       ret = BT_FALSE;
                        goto end;
                }
 
@@ -381,10 +410,10 @@ end:
 }
 
 static
-bool bt_value_map_compare(const struct bt_value *object_a,
+bt_bool bt_value_map_compare(const struct bt_value *object_a,
                const struct bt_value *object_b)
 {
-       bool ret = true;
+       bt_bool ret = BT_TRUE;
        GHashTableIter iter;
        gpointer key, element_obj_a;
        const struct bt_value_map *map_obj_a = BT_VALUE_TO_MAP(object_a);
@@ -396,7 +425,7 @@ bool bt_value_map_compare(const struct bt_value *object_a,
                        object_a, object_b,
                        bt_value_map_size(object_a),
                        bt_value_map_size(object_b));
-               ret = false;
+               ret = BT_FALSE;
                goto end;
        }
 
@@ -413,7 +442,7 @@ bool bt_value_map_compare(const struct bt_value *object_a,
                                "value-a-addr=%p, value-b-addr=%p, key=\"%s\"",
                                element_obj_a, element_obj_b, key_str);
                        BT_PUT(element_obj_b);
-                       ret = false;
+                       ret = BT_FALSE;
                        goto end;
                }
 
@@ -425,14 +454,14 @@ end:
 }
 
 static
-bool (* const compare_funcs[])(const struct bt_value *,
+bt_bool (* const compare_funcs[])(const struct bt_value *,
                const struct bt_value *) = {
        [BT_VALUE_TYPE_NULL] =          bt_value_null_compare,
        [BT_VALUE_TYPE_BOOL] =          bt_value_bool_compare,
        [BT_VALUE_TYPE_INTEGER] =       bt_value_integer_compare,
-       [BT_VALUE_TYPE_FLOAT] = bt_value_float_compare,
+       [BT_VALUE_TYPE_FLOAT] =         bt_value_float_compare,
        [BT_VALUE_TYPE_STRING] =        bt_value_string_compare,
-       [BT_VALUE_TYPE_ARRAY] = bt_value_array_compare,
+       [BT_VALUE_TYPE_ARRAY] =         bt_value_array_compare,
        [BT_VALUE_TYPE_MAP] =           bt_value_map_compare,
 };
 
@@ -442,7 +471,7 @@ void bt_value_null_freeze(struct bt_value *object)
 
 void bt_value_generic_freeze(struct bt_value *object)
 {
-       object->is_frozen = true;
+       object->is_frozen = BT_TRUE;
 }
 
 void bt_value_array_freeze(struct bt_value *object)
@@ -494,7 +523,6 @@ void bt_value_destroy(struct bt_object *obj)
 
        value = container_of(obj, struct bt_value, base);
        assert(value->type != BT_VALUE_TYPE_UNKNOWN);
-
        BT_LOGD("Destroying value: addr=%p", value);
 
        if (bt_value_is_null(value)) {
@@ -530,7 +558,7 @@ end:
        return ret;
 }
 
-bool bt_value_is_frozen(const struct bt_value *object)
+bt_bool bt_value_is_frozen(const struct bt_value *object)
 {
        return object && object->is_frozen;
 }
@@ -538,7 +566,11 @@ bool bt_value_is_frozen(const struct bt_value *object)
 enum bt_value_type bt_value_get_type(const struct bt_value *object)
 {
        if (!object) {
-               BT_LOGW_STR("Invalid parameter: value object is NULL.");
+               /*
+                * Not an error: user can test NULL value object with
+                * this function.
+                */
+               BT_LOGV_STR("Value object is NULL.");
                return BT_VALUE_TYPE_UNKNOWN;
        }
 
@@ -551,12 +583,12 @@ struct bt_value bt_value_create_base(enum bt_value_type type)
        struct bt_value base;
 
        base.type = type;
-       base.is_frozen = false;
+       base.is_frozen = BT_FALSE;
        bt_object_init(&base, bt_value_destroy);
        return base;
 }
 
-struct bt_value *bt_value_bool_create_init(bool val)
+struct bt_value *bt_value_bool_create_init(bt_bool val)
 {
        struct bt_value_bool *bool_obj;
 
@@ -578,7 +610,7 @@ end:
 
 struct bt_value *bt_value_bool_create(void)
 {
-       return bt_value_bool_create_init(false);
+       return bt_value_bool_create_init(BT_FALSE);
 }
 
 struct bt_value *bt_value_integer_create_init(int64_t val)
@@ -642,7 +674,7 @@ struct bt_value *bt_value_string_create_init(const char *val)
                goto end;
        }
 
-       BT_LOGD("Creating string value object: val-len=%u", strlen(val));
+       BT_LOGD("Creating string value object: val-len=%zu", strlen(val));
        string_obj = g_new0(struct bt_value_string, 1);
 
        if (!string_obj) {
@@ -733,7 +765,7 @@ end:
 }
 
 enum bt_value_status bt_value_bool_get(const struct bt_value *bool_obj,
-               bool *val)
+               bt_bool *val)
 {
        enum bt_value_status ret = BT_VALUE_STATUS_OK;
        struct bt_value_bool *typed_bool_obj = BT_VALUE_TO_BOOL(bool_obj);
@@ -748,7 +780,8 @@ enum bt_value_status bt_value_bool_get(const struct bt_value *bool_obj,
 
        if (!bt_value_is_bool(bool_obj)) {
                BT_LOGW("Invalid parameter: value is not a boolean value: addr=%p, "
-                       "type=%d", bool_obj, bool_obj->type);
+                       "type=%s", bool_obj,
+                       bt_value_type_string(bool_obj->type));
                ret = BT_VALUE_STATUS_INVAL;
                goto end;
        }
@@ -759,7 +792,7 @@ end:
        return ret;
 }
 
-enum bt_value_status bt_value_bool_set(struct bt_value *bool_obj, bool val)
+enum bt_value_status bt_value_bool_set(struct bt_value *bool_obj, bt_bool val)
 {
        enum bt_value_status ret = BT_VALUE_STATUS_OK;
        struct bt_value_bool *typed_bool_obj = BT_VALUE_TO_BOOL(bool_obj);
@@ -772,7 +805,8 @@ enum bt_value_status bt_value_bool_set(struct bt_value *bool_obj, bool val)
 
        if (!bt_value_is_bool(bool_obj)) {
                BT_LOGW("Invalid parameter: value is not a boolean value: addr=%p, "
-                       "type=%d", bool_obj, bool_obj->type);
+                       "type=%s", bool_obj,
+                       bt_value_type_string(bool_obj->type));
                ret = BT_VALUE_STATUS_INVAL;
                goto end;
        }
@@ -809,7 +843,8 @@ enum bt_value_status bt_value_integer_get(const struct bt_value *integer_obj,
 
        if (!bt_value_is_integer(integer_obj)) {
                BT_LOGW("Invalid parameter: value is not an integer value: addr=%p, "
-                       "type=%d", integer_obj, integer_obj->type);
+                       "type=%s", integer_obj,
+                       bt_value_type_string(integer_obj->type));
                ret = BT_VALUE_STATUS_INVAL;
                goto end;
        }
@@ -835,7 +870,8 @@ enum bt_value_status bt_value_integer_set(struct bt_value *integer_obj,
 
        if (!bt_value_is_integer(integer_obj)) {
                BT_LOGW("Invalid parameter: value is not an integer value: addr=%p, "
-                       "type=%d", integer_obj, integer_obj->type);
+                       "type=%s", integer_obj,
+                       bt_value_type_string(integer_obj->type));
                ret = BT_VALUE_STATUS_INVAL;
                goto end;
        }
@@ -872,7 +908,8 @@ enum bt_value_status bt_value_float_get(const struct bt_value *float_obj,
 
        if (!bt_value_is_float(float_obj)) {
                BT_LOGW("Invalid parameter: value is not a floating point number value: addr=%p, "
-                       "type=%d", float_obj, float_obj->type);
+                       "type=%s", float_obj,
+                       bt_value_type_string(float_obj->type));
                ret = BT_VALUE_STATUS_INVAL;
                goto end;
        }
@@ -898,7 +935,8 @@ enum bt_value_status bt_value_float_set(struct bt_value *float_obj,
 
        if (!bt_value_is_float(float_obj)) {
                BT_LOGW("Invalid parameter: value is not a floating point number value: addr=%p, "
-                       "type=%d", float_obj, float_obj->type);
+                       "type=%s", float_obj,
+                       bt_value_type_string(float_obj->type));
                ret = BT_VALUE_STATUS_INVAL;
                goto end;
        }
@@ -935,7 +973,8 @@ enum bt_value_status bt_value_string_get(const struct bt_value *string_obj,
 
        if (!bt_value_is_string(string_obj)) {
                BT_LOGW("Invalid parameter: value is not a string value: addr=%p, "
-                       "type=%d", string_obj, string_obj->type);
+                       "type=%s", string_obj,
+                       bt_value_type_string(string_obj->type));
                ret = BT_VALUE_STATUS_INVAL;
                goto end;
        }
@@ -963,7 +1002,8 @@ enum bt_value_status bt_value_string_set(struct bt_value *string_obj,
 
        if (!bt_value_is_string(string_obj)) {
                BT_LOGW("Invalid parameter: value is not a string value: addr=%p, "
-                       "type=%d", string_obj, string_obj->type);
+                       "type=%s", string_obj,
+                       bt_value_type_string(string_obj->type));
                ret = BT_VALUE_STATUS_INVAL;
                goto end;
        }
@@ -997,7 +1037,8 @@ int64_t bt_value_array_size(const struct bt_value *array_obj)
 
        if (!bt_value_is_array(array_obj)) {
                BT_LOGW("Invalid parameter: value is not an array value: addr=%p, "
-                       "type=%d", array_obj, array_obj->type);
+                       "type=%s", array_obj,
+                       bt_value_type_string(array_obj->type));
                ret = BT_VALUE_STATUS_INVAL;
                goto end;
        }
@@ -1008,7 +1049,7 @@ end:
        return ret;
 }
 
-bool bt_value_array_is_empty(const struct bt_value *array_obj)
+bt_bool bt_value_array_is_empty(const struct bt_value *array_obj)
 {
        return bt_value_array_size(array_obj) == 0;
 }
@@ -1029,15 +1070,16 @@ struct bt_value *bt_value_array_get(const struct bt_value *array_obj,
 
        if (!bt_value_is_array(array_obj)) {
                BT_LOGW("Invalid parameter: value is not an array value: addr=%p, "
-                       "type=%d", array_obj, array_obj->type);
+                       "type=%s", array_obj,
+                       bt_value_type_string(array_obj->type));
                ret = NULL;
                goto end;
        }
 
        if (index >= typed_array_obj->garray->len) {
                BT_LOGW("Invalid parameter: index is out of bounds: "
-                       "addr=%p, index=%" PRIu64,
-                       array_obj, index);
+                       "addr=%p, index=%" PRIu64 ", size=%u",
+                       array_obj, index, typed_array_obj->garray->len);
                ret = NULL;
                goto end;
        }
@@ -1066,7 +1108,8 @@ enum bt_value_status bt_value_array_append(struct bt_value *array_obj,
 
        if (!bt_value_is_array(array_obj)) {
                BT_LOGW("Invalid parameter: value is not an array value: addr=%p, "
-                       "type=%d", array_obj, array_obj->type);
+                       "type=%s", array_obj,
+                       bt_value_type_string(array_obj->type));
                ret = BT_VALUE_STATUS_INVAL;
                goto end;
        }
@@ -1089,7 +1132,7 @@ end:
 }
 
 enum bt_value_status bt_value_array_append_bool(struct bt_value *array_obj,
-               bool val)
+               bt_bool val)
 {
        enum bt_value_status ret;
        struct bt_value *bool_obj = NULL;
@@ -1176,15 +1219,16 @@ enum bt_value_status bt_value_array_set(struct bt_value *array_obj,
 
        if (!bt_value_is_array(array_obj)) {
                BT_LOGW("Invalid parameter: value is not an array value: addr=%p, "
-                       "type=%d", array_obj, array_obj->type);
+                       "type=%s", array_obj,
+                       bt_value_type_string(array_obj->type));
                ret = BT_VALUE_STATUS_INVAL;
                goto end;
        }
 
        if (index >= typed_array_obj->garray->len) {
                BT_LOGW("Invalid parameter: index is out of bounds: "
-                       "addr=%p, index=%" PRIu64,
-                       array_obj, index);
+                       "addr=%p, index=%" PRIu64 ", size=%u",
+                       array_obj, index, typed_array_obj->garray->len);
                ret = BT_VALUE_STATUS_INVAL;
                goto end;
        }
@@ -1220,7 +1264,8 @@ int64_t bt_value_map_size(const struct bt_value *map_obj)
 
        if (!bt_value_is_map(map_obj)) {
                BT_LOGW("Invalid parameter: value is not a map value: addr=%p, "
-                       "type=%d", map_obj, map_obj->type);
+                       "type=%s", map_obj,
+                       bt_value_type_string(map_obj->type));
                ret = (int64_t) BT_VALUE_STATUS_INVAL;
                goto end;
        }
@@ -1231,7 +1276,7 @@ end:
        return ret;
 }
 
-bool bt_value_map_is_empty(const struct bt_value *map_obj)
+bt_bool bt_value_map_is_empty(const struct bt_value *map_obj)
 {
        return bt_value_map_size(map_obj) == 0;
 }
@@ -1252,14 +1297,14 @@ struct bt_value *bt_value_map_get(const struct bt_value *map_obj,
 
        if (!bt_value_is_map(map_obj)) {
                BT_LOGW("Invalid parameter: value is not a map value: addr=%p, "
-                       "type=%d", map_obj, map_obj->type);
+                       "type=%s", map_obj,
+                       bt_value_type_string(map_obj->type));
                ret = NULL;
                goto end;
        }
 
        quark = g_quark_from_string(key);
        ret = g_hash_table_lookup(typed_map_obj->ght, GUINT_TO_POINTER(quark));
-
        if (ret) {
                bt_get(ret);
        }
@@ -1268,23 +1313,24 @@ end:
        return ret;
 }
 
-bool bt_value_map_has_key(const struct bt_value *map_obj, const char *key)
+bt_bool bt_value_map_has_key(const struct bt_value *map_obj, const char *key)
 {
-       bool ret;
+       bt_bool ret;
        GQuark quark;
        struct bt_value_map *typed_map_obj = BT_VALUE_TO_MAP(map_obj);
 
        if (!map_obj || !key) {
                BT_LOGW("Invalid parameter: value object or key is NULL: "
                        "value-addr=%p, key-addr=%p", map_obj, key);
-               ret = false;
+               ret = BT_FALSE;
                goto end;
        }
 
        if (!bt_value_is_map(map_obj)) {
                BT_LOGW("Invalid parameter: value is not a map value: addr=%p, "
-                       "type=%d", map_obj, map_obj->type);
-               ret = false;
+                       "type=%s", map_obj,
+                       bt_value_type_string(map_obj->type));
+               ret = BT_FALSE;
                goto end;
        }
 
@@ -1313,7 +1359,8 @@ enum bt_value_status bt_value_map_insert(struct bt_value *map_obj,
 
        if (!bt_value_is_map(map_obj)) {
                BT_LOGW("Invalid parameter: value is not a map value: addr=%p, "
-                       "type=%d", map_obj, map_obj->type);
+                       "type=%s", map_obj,
+                       bt_value_type_string(map_obj->type));
                ret = BT_VALUE_STATUS_INVAL;
                goto end;
        }
@@ -1338,7 +1385,7 @@ end:
 }
 
 enum bt_value_status bt_value_map_insert_bool(struct bt_value *map_obj,
-               const char *key, bool val)
+               const char *key, bt_bool val)
 {
        enum bt_value_status ret;
        struct bt_value *bool_obj = NULL;
@@ -1426,7 +1473,8 @@ enum bt_value_status bt_value_map_foreach(const struct bt_value *map_obj,
 
        if (!bt_value_is_map(map_obj)) {
                BT_LOGW("Invalid parameter: value is not a map value: addr=%p, "
-                       "type=%d", map_obj, map_obj->type);
+                       "type=%s", map_obj,
+                       bt_value_type_string(map_obj->type));
                ret = BT_VALUE_STATUS_INVAL;
                goto end;
        }
@@ -1437,7 +1485,7 @@ enum bt_value_status bt_value_map_foreach(const struct bt_value *map_obj,
                const char *key_str = g_quark_to_string(GPOINTER_TO_UINT(key));
 
                if (!cb(key_str, element_obj, data)) {
-                       BT_LOGD("User cancelled the loop: key=\"%s\", "
+                       BT_LOGV("User cancelled the loop: key=\"%s\", "
                                "value-addr=%p, data=%p",
                                key_str, element_obj, data);
                        ret = BT_VALUE_STATUS_CANCELLED;
@@ -1451,14 +1499,14 @@ end:
 
 struct extend_map_element_data {
        struct bt_value *extended_obj;
-       bool got_error;
+       bt_bool got_error;
 };
 
 static
-bool extend_map_element(const char *key,
+bt_bool extend_map_element(const char *key,
                struct bt_value *extension_obj_elem, void *data)
 {
-       bool ret = true;
+       bt_bool ret = BT_TRUE;
 
        struct extend_map_element_data *extend_data = data;
 
@@ -1479,8 +1527,8 @@ bool extend_map_element(const char *key,
        goto end;
 
 error:
-       ret = false;
-       extend_data->got_error = true;
+       ret = BT_FALSE;
+       extend_data->got_error = BT_TRUE;
 
 end:
        BT_PUT(extension_obj_elem_copy);
@@ -1502,13 +1550,15 @@ struct bt_value *bt_value_map_extend(struct bt_value *base_map_obj,
 
        if (!bt_value_is_map(base_map_obj)) {
                BT_LOGW("Invalid parameter: value is not a map value: addr=%p, "
-                       "type=%d", base_map_obj, base_map_obj->type);
+                       "type=%s", base_map_obj,
+                       bt_value_type_string(base_map_obj->type));
                goto error;
        }
 
        if (!bt_value_is_map(extension_obj)) {
                BT_LOGW("Invalid parameter: value is not a map value: addr=%p, "
-                       "type=%d", extension_obj, extension_obj->type);
+                       "type=%s", extension_obj,
+                       bt_value_type_string(extension_obj->type));
                goto error;
        }
 
@@ -1531,13 +1581,13 @@ struct bt_value *bt_value_map_extend(struct bt_value *base_map_obj,
 
        if (bt_value_map_foreach(extension_obj, extend_map_element,
                        &extend_data)) {
-               BT_LOGE("Cannot iterate on the extension object's elements: ",
+               BT_LOGE("Cannot iterate on the extension object's elements: "
                        "extension-value-addr=%p", extension_obj);
                goto error;
        }
 
        if (extend_data.got_error) {
-               BT_LOGE("Failed to successfully iterate on the extension object's elements: ",
+               BT_LOGE("Failed to successfully iterate on the extension object's elements: "
                        "extension-value-addr=%p", extension_obj);
                goto error;
        }
@@ -1575,10 +1625,10 @@ end:
        return copy_obj;
 }
 
-bool bt_value_compare(const struct bt_value *object_a,
+bt_bool bt_value_compare(const struct bt_value *object_a,
        const struct bt_value *object_b)
 {
-       bool ret = false;
+       bt_bool ret = BT_FALSE;
 
        if (!object_a || !object_b) {
                BT_LOGW("Invalid parameter: value A or value B is NULL: "
@@ -1590,9 +1640,10 @@ bool bt_value_compare(const struct bt_value *object_a,
        if (object_a->type != object_b->type) {
                BT_LOGV("Values are different: type mismatch: "
                        "value-a-addr=%p, value-b-addr=%p, "
-                       "value-a-type=%d, value-b-type=%d",
+                       "value-a-type=%s, value-b-type=%s",
                        object_a, object_b,
-                       object_a->type, object_b->type);
+                       bt_value_type_string(object_a->type),
+                       bt_value_type_string(object_b->type));
                goto end;
        }
 
This page took 0.04647 seconds and 4 git commands to generate.