Replace all assert(false) and assert(0) with abort()
[babeltrace.git] / lib / ctf-ir / event-class.c
index 5be7e7adae1591e694dadbaf3fe914641ee2349b..3fc60603103bdda8f4d63e7aaf732b8c294fdbb0 100644 (file)
@@ -45,6 +45,7 @@
 #include <babeltrace/types.h>
 #include <babeltrace/values-internal.h>
 #include <inttypes.h>
+#include <stdlib.h>
 
 static
 void bt_ctf_event_class_destroy(struct bt_object *obj);
@@ -304,6 +305,7 @@ int bt_ctf_event_class_set_attribute(
 
                ret = bt_value_integer_get(value, &val);
                assert(ret == 0);
+               BT_LOGV("Setting event's ID: id=%" PRId64, val);
                ret = bt_ctf_event_class_set_id(event_class, (uint64_t) val);
                if (ret) {
                        goto end;
@@ -377,7 +379,7 @@ bt_ctf_event_class_get_attribute_name_by_index(
        }
 
        ret = bt_ctf_attributes_get_field_name(event_class->attributes, index);
-       if (ret) {
+       if (!ret) {
                BT_LOGW("Cannot get event class's attribute name by index: "
                        "addr=%p, name=\"%s\", id=%" PRId64 ", index=%" PRIu64,
                        event_class, bt_ctf_event_class_get_name(event_class),
@@ -401,7 +403,7 @@ bt_ctf_event_class_get_attribute_value_by_index(
        }
 
        ret = bt_ctf_attributes_get_field_value(event_class->attributes, index);
-       if (ret) {
+       if (!ret) {
                BT_LOGW("Cannot get event class's attribute value by index: "
                        "addr=%p, name=\"%s\", id=%" PRId64 ", index=%" PRIu64,
                        event_class, bt_ctf_event_class_get_name(event_class),
@@ -419,7 +421,7 @@ bt_ctf_event_class_get_attribute_value_by_name(
        struct bt_value *ret;
 
        if (!event_class || !name) {
-               BT_LOGW("Invalid parameter: event class or name is NULL: ",
+               BT_LOGW("Invalid parameter: event class or name is NULL: "
                        "event-class-addr=%p, name-addr=%p",
                        event_class, name);
                ret = NULL;
@@ -428,7 +430,7 @@ bt_ctf_event_class_get_attribute_value_by_name(
 
        ret = bt_ctf_attributes_get_field_value_by_name(event_class->attributes,
                name);
-       if (ret) {
+       if (!ret) {
                BT_LOGV("Cannot find event class's attribute: "
                        "addr=%p, event-class-name=\"%s\", id=%" PRId64 ", "
                        "attr-name=\"%s\"",
@@ -620,7 +622,7 @@ bt_ctf_event_class_get_payload_type_field_type_by_name(
        struct bt_ctf_field_type *field_type = NULL;
 
        if (!event_class || !name) {
-               BT_LOGW("Invalid parameter: event class or name is NULL: ",
+               BT_LOGW("Invalid parameter: event class or name is NULL: "
                        "event-class-addr=%p, name-addr=%p",
                        event_class, name);
                goto end;
@@ -786,8 +788,11 @@ void bt_ctf_event_class_destroy(struct bt_object *obj)
        BT_LOGD("Destroying event class: addr=%p, name=\"%s\", id=%" PRId64,
                event_class, bt_ctf_event_class_get_name(event_class),
                bt_ctf_event_class_get_id(event_class));
+       BT_LOGD_STR("Destroying event class's attributes.");
        bt_ctf_attributes_destroy(event_class->attributes);
+       BT_LOGD_STR("Putting context field type.");
        bt_put(event_class->context);
+       BT_LOGD_STR("Putting payload field type.");
        bt_put(event_class->fields);
        g_free(event_class);
 }
@@ -807,8 +812,11 @@ void bt_ctf_event_class_freeze(struct bt_ctf_event_class *event_class)
        event_class->frozen = 1;
        event_class->name = bt_ctf_event_class_get_name(event_class);
        event_class->id = bt_ctf_event_class_get_id(event_class);
+       BT_LOGD_STR("Freezing event class's context field type.");
        bt_ctf_field_type_freeze(event_class->context);
+       BT_LOGD_STR("Freezing event class's payload field type.");
        bt_ctf_field_type_freeze(event_class->fields);
+       BT_LOGD_STR("Freezing event class's attributes.");
        bt_ctf_attributes_freeze(event_class->attributes);
 }
 
@@ -869,7 +877,7 @@ int bt_ctf_event_class_serialize(struct bt_ctf_event_class *event_class,
 
                default:
                        /* should never happen */
-                       assert(BT_FALSE);
+                       abort();
                        break;
                }
 
@@ -878,10 +886,11 @@ int bt_ctf_event_class_serialize(struct bt_ctf_event_class *event_class,
 
        if (event_class->context) {
                g_string_append(context->string, "\tcontext := ");
+               BT_LOGD_STR("Serializing event class's context field type metadata.");
                ret = bt_ctf_field_type_serialize(event_class->context,
                        context);
                if (ret) {
-                       BT_LOGE("Cannot serialize event class's context field type's metadata: "
+                       BT_LOGW("Cannot serialize event class's context field type's metadata: "
                                "ret=%d", ret);
                        goto end;
                }
@@ -890,9 +899,10 @@ int bt_ctf_event_class_serialize(struct bt_ctf_event_class *event_class,
 
        if (event_class->fields) {
                g_string_append(context->string, "\tfields := ");
+               BT_LOGD_STR("Serializing event class's payload field type metadata.");
                ret = bt_ctf_field_type_serialize(event_class->fields, context);
                if (ret) {
-                       BT_LOGE("Cannot serialize event class's payload field type's metadata: "
+                       BT_LOGW("Cannot serialize event class's payload field type's metadata: "
                                "ret=%d", ret);
                        goto end;
                }
This page took 0.025969 seconds and 4 git commands to generate.