lib: use BT_LIB_LOG*_APPEND_CAUSE() where appropriate
[babeltrace.git] / src / lib / trace-ir / field-class.c
index b6a1f65de0773190a3df2efc4f741ebfa6a035d1..4c3de506e875e45b97e8f81cf35230d1f930f34a 100644 (file)
@@ -22,7 +22,7 @@
  */
 
 #define BT_LOG_TAG "LIB/FIELD-CLASS"
-#include "lib/lib-logging.h"
+#include "lib/logging.h"
 
 #include "lib/assert-pre.h"
 #include <babeltrace2/trace-ir/field-class.h>
@@ -44,6 +44,7 @@
 #include "field.h"
 #include "field-path.h"
 #include "utils.h"
+#include "lib/func-status.h"
 
 enum bt_field_class_type bt_field_class_get_type(
                const struct bt_field_class *fc)
@@ -92,7 +93,8 @@ struct bt_field_class *create_integer_field_class(bt_trace_class *trace_class,
                bt_common_field_class_type_string(type));
        int_fc = g_new0(struct bt_field_class_integer, 1);
        if (!int_fc) {
-               BT_LOGE_STR("Failed to allocate one integer field class.");
+               BT_LIB_LOGE_APPEND_CAUSE(
+                       "Failed to allocate one integer field class.");
                goto error;
        }
 
@@ -239,7 +241,8 @@ struct bt_field_class *create_enumeration_field_class(
                bt_common_field_class_type_string(type));
        enum_fc = g_new0(struct bt_field_class_enumeration, 1);
        if (!enum_fc) {
-               BT_LOGE_STR("Failed to allocate one enumeration field class.");
+               BT_LIB_LOGE_APPEND_CAUSE(
+                       "Failed to allocate one enumeration field class.");
                goto error;
        }
 
@@ -248,13 +251,13 @@ struct bt_field_class *create_enumeration_field_class(
        enum_fc->mappings = g_array_new(FALSE, TRUE,
                sizeof(struct bt_field_class_enumeration_mapping));
        if (!enum_fc->mappings) {
-               BT_LOGE_STR("Failed to allocate a GArray.");
+               BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GArray.");
                goto error;
        }
 
        enum_fc->label_buf = g_ptr_array_new();
        if (!enum_fc->label_buf) {
-               BT_LOGE_STR("Failed to allocate a GArray.");
+               BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GArray.");
                goto error;
        }
 
@@ -365,7 +368,7 @@ void bt_field_class_signed_enumeration_mapping_get_range_by_index(
                (uint64_t *) lower, (uint64_t *) upper);
 }
 
-enum bt_field_class_status
+enum bt_field_class_enumeration_get_mapping_labels_by_value_status
 bt_field_class_unsigned_enumeration_get_mapping_labels_by_value(
                const struct bt_field_class *fc, uint64_t value,
                bt_field_class_enumeration_mapping_label_array *label_array,
@@ -402,10 +405,10 @@ bt_field_class_unsigned_enumeration_get_mapping_labels_by_value(
 
        *label_array = (void *) enum_fc->label_buf->pdata;
        *count = (uint64_t) enum_fc->label_buf->len;
-       return BT_FIELD_CLASS_STATUS_OK;
+       return BT_FUNC_STATUS_OK;
 }
 
-enum bt_field_class_status
+enum bt_field_class_enumeration_get_mapping_labels_by_value_status
 bt_field_class_signed_enumeration_get_mapping_labels_by_value(
                const struct bt_field_class *fc, int64_t value,
                bt_field_class_enumeration_mapping_label_array *label_array,
@@ -442,15 +445,16 @@ bt_field_class_signed_enumeration_get_mapping_labels_by_value(
 
        *label_array = (void *) enum_fc->label_buf->pdata;
        *count = (uint64_t) enum_fc->label_buf->len;
-       return BT_FIELD_CLASS_STATUS_OK;
+       return BT_FUNC_STATUS_OK;
 }
 
 static inline
-enum bt_field_class_status add_mapping_to_enumeration_field_class(
+enum bt_field_class_enumeration_map_range_status
+add_mapping_to_enumeration_field_class(
                struct bt_field_class *fc,
                const char *label, uint64_t lower, uint64_t upper)
 {
-       int ret = BT_FIELD_CLASS_STATUS_OK;
+       int ret = BT_FUNC_STATUS_OK;
        uint64_t i;
        struct bt_field_class_enumeration *enum_fc = (void *) fc;
        struct bt_field_class_enumeration_mapping *mapping = NULL;
@@ -481,7 +485,7 @@ enum bt_field_class_status add_mapping_to_enumeration_field_class(
                        finalize_enumeration_field_class_mapping(mapping);
                        g_array_set_size(enum_fc->mappings,
                                enum_fc->mappings->len - 1);
-                       ret = BT_FIELD_CLASS_STATUS_NOMEM;
+                       ret = BT_FUNC_STATUS_MEMORY_ERROR;
                        goto end;
                }
 
@@ -490,7 +494,7 @@ enum bt_field_class_status add_mapping_to_enumeration_field_class(
                        finalize_enumeration_field_class_mapping(mapping);
                        g_array_set_size(enum_fc->mappings,
                                enum_fc->mappings->len - 1);
-                       ret = BT_FIELD_CLASS_STATUS_NOMEM;
+                       ret = BT_FUNC_STATUS_MEMORY_ERROR;
                        goto end;
                }
        }
@@ -510,7 +514,7 @@ end:
        return ret;
 }
 
-enum bt_field_class_status bt_field_class_unsigned_enumeration_map_range(
+enum bt_field_class_enumeration_map_range_status bt_field_class_unsigned_enumeration_map_range(
                struct bt_field_class *fc, const char *label,
                uint64_t range_lower, uint64_t range_upper)
 {
@@ -535,7 +539,7 @@ enum bt_field_class_status bt_field_class_unsigned_enumeration_map_range(
                range_upper);
 }
 
-enum bt_field_class_status bt_field_class_signed_enumeration_map_range(
+enum bt_field_class_enumeration_map_range_status bt_field_class_signed_enumeration_map_range(
                struct bt_field_class *fc, const char *label,
                int64_t range_lower, int64_t range_upper)
 {
@@ -576,7 +580,7 @@ struct bt_field_class *bt_field_class_real_create(bt_trace_class *trace_class)
        BT_LOGD_STR("Creating default real field class object.");
        real_fc = g_new0(struct bt_field_class_real, 1);
        if (!real_fc) {
-               BT_LOGE_STR("Failed to allocate one real field class.");
+               BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one real field class.");
                goto error;
        }
 
@@ -626,14 +630,14 @@ int init_named_field_classes_container(
        fc->named_fcs = g_array_new(FALSE, TRUE,
                sizeof(struct bt_named_field_class));
        if (!fc->named_fcs) {
-               BT_LOGE_STR("Failed to allocate a GArray.");
+               BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GArray.");
                ret = -1;
                goto end;
        }
 
        fc->name_to_index = g_hash_table_new(g_str_hash, g_str_equal);
        if (!fc->name_to_index) {
-               BT_LOGE_STR("Failed to allocate a GHashTable.");
+               BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GHashTable.");
                ret = -1;
                goto end;
        }
@@ -701,7 +705,8 @@ struct bt_field_class *bt_field_class_structure_create(
        BT_LOGD_STR("Creating default structure field class object.");
        struct_fc = g_new0(struct bt_field_class_structure, 1);
        if (!struct_fc) {
-               BT_LOGE_STR("Failed to allocate one structure field class.");
+               BT_LIB_LOGE_APPEND_CAUSE(
+                       "Failed to allocate one structure field class.");
                goto error;
        }
 
@@ -722,11 +727,11 @@ end:
 }
 
 static
-enum bt_field_class_status append_named_field_class_to_container_field_class(
+int append_named_field_class_to_container_field_class(
                struct bt_field_class_named_field_class_container *container_fc,
                const char *name, struct bt_field_class *fc)
 {
-       int ret = BT_FIELD_CLASS_STATUS_OK;
+       int ret = BT_FUNC_STATUS_OK;
        struct bt_named_field_class *named_fc;
        GString *name_str;
 
@@ -740,8 +745,8 @@ enum bt_field_class_status append_named_field_class_to_container_field_class(
                "%![container-fc-]+F, name=\"%s\"", container_fc, name);
        name_str = g_string_new(name);
        if (!name_str) {
-               BT_LOGE_STR("Failed to allocate a GString.");
-               ret = BT_FIELD_CLASS_STATUS_NOMEM;
+               BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GString.");
+               ret = BT_FUNC_STATUS_MEMORY_ERROR;
                goto end;
        }
 
@@ -766,7 +771,8 @@ end:
        return ret;
 }
 
-enum bt_field_class_status bt_field_class_structure_append_member(
+enum bt_field_class_structure_append_member_status
+bt_field_class_structure_append_member(
                struct bt_field_class *fc, const char *name,
                struct bt_field_class *member_fc)
 {
@@ -926,7 +932,8 @@ struct bt_field_class *bt_field_class_variant_create(
        BT_LOGD_STR("Creating default variant field class object.");
        var_fc = g_new0(struct bt_field_class_variant, 1);
        if (!var_fc) {
-               BT_LOGE_STR("Failed to allocate one variant field class.");
+               BT_LIB_LOGE_APPEND_CAUSE(
+                       "Failed to allocate one variant field class.");
                goto error;
        }
 
@@ -946,7 +953,8 @@ end:
        return (void *) var_fc;
 }
 
-enum bt_field_class_status bt_field_class_variant_set_selector_field_class(
+enum bt_field_class_variant_set_selector_field_class_status
+bt_field_class_variant_set_selector_field_class(
                struct bt_field_class *fc,
                struct bt_field_class *selector_fc)
 {
@@ -960,10 +968,11 @@ enum bt_field_class_status bt_field_class_variant_set_selector_field_class(
        var_fc->selector_fc = selector_fc;
        bt_object_get_no_null_check(selector_fc);
        bt_field_class_freeze(selector_fc);
-       return BT_FIELD_CLASS_STATUS_OK;
+       return BT_FUNC_STATUS_OK;
 }
 
-enum bt_field_class_status bt_field_class_variant_append_option(
+enum bt_field_class_variant_append_option_status
+bt_field_class_variant_append_option(
                struct bt_field_class *fc,
                const char *name, struct bt_field_class *option_fc)
 {
@@ -1108,7 +1117,8 @@ bt_field_class_static_array_create(bt_trace_class *trace_class,
        BT_LOGD_STR("Creating default static array field class object.");
        array_fc = g_new0(struct bt_field_class_static_array, 1);
        if (!array_fc) {
-               BT_LOGE_STR("Failed to allocate one static array field class.");
+               BT_LIB_LOGE_APPEND_CAUSE(
+                       "Failed to allocate one static array field class.");
                goto error;
        }
 
@@ -1182,7 +1192,8 @@ struct bt_field_class *bt_field_class_dynamic_array_create(
        BT_LOGD_STR("Creating default dynamic array field class object.");
        array_fc = g_new0(struct bt_field_class_dynamic_array, 1);
        if (!array_fc) {
-               BT_LOGE_STR("Failed to allocate one dynamic array field class.");
+               BT_LIB_LOGE_APPEND_CAUSE(
+                       "Failed to allocate one dynamic array field class.");
                goto error;
        }
 
@@ -1199,7 +1210,8 @@ end:
        return (void *) array_fc;
 }
 
-enum bt_field_class_status bt_field_class_dynamic_array_set_length_field_class(
+enum bt_field_class_dynamic_array_set_length_field_class_status
+bt_field_class_dynamic_array_set_length_field_class(
                struct bt_field_class *fc,
                struct bt_field_class *length_fc)
 {
@@ -1214,7 +1226,7 @@ enum bt_field_class_status bt_field_class_dynamic_array_set_length_field_class(
        array_fc->length_fc = length_fc;
        bt_object_get_no_null_check(length_fc);
        bt_field_class_freeze(length_fc);
-       return BT_FIELD_CLASS_STATUS_OK;
+       return BT_FUNC_STATUS_OK;
 }
 
 const struct bt_field_path *
@@ -1245,7 +1257,8 @@ struct bt_field_class *bt_field_class_string_create(bt_trace_class *trace_class)
        BT_LOGD_STR("Creating default string field class object.");
        string_fc = g_new0(struct bt_field_class_string, 1);
        if (!string_fc) {
-               BT_LOGE_STR("Failed to allocate one string field class.");
+               BT_LIB_LOGE_APPEND_CAUSE(
+                       "Failed to allocate one string field class.");
                goto error;
        }
 
This page took 0.027803 seconds and 4 git commands to generate.