Always evaluate BT_ASSERT(); add BT_ASSERT_DBG() for debug mode only
[babeltrace.git] / src / plugins / text / details / obj-lifetime-mgmt.c
index fc749046e28e330d897f4d7218974502f42c8db8..41a2a31e0c3c02d456cfc8619d88e4f49fe9a527 100644 (file)
@@ -20,9 +20,6 @@
  * SOFTWARE.
  */
 
-#define BT_LOG_TAG "PLUGIN-TEXT-DETAILS-SINK-OBJ-LIFETIME-MGMT"
-#include "logging.h"
-
 #include <babeltrace2/babeltrace.h>
 
 #include "common/common.h"
@@ -51,8 +48,8 @@ struct details_trace_class_meta *borrow_trace_class_meta(
 {
        struct details_trace_class_meta *details_tc_meta;
 
-       BT_ASSERT(ctx->details_comp->cfg.with_meta);
-       BT_ASSERT(ctx->details_comp->meta);
+       BT_ASSERT_DBG(ctx->details_comp->cfg.with_meta);
+       BT_ASSERT_DBG(ctx->details_comp->meta);
        details_tc_meta = g_hash_table_lookup(ctx->details_comp->meta, tc);
        if (!details_tc_meta) {
                /* Not found: create one */
@@ -96,11 +93,11 @@ bool details_need_to_write_meta_object(struct details_write_ctx *ctx,
                goto end;
        }
 
-       BT_ASSERT(ctx->details_comp->meta);
+       BT_ASSERT_DBG(ctx->details_comp->meta);
        details_tc_meta = g_hash_table_lookup(ctx->details_comp->meta, tc);
-       BT_ASSERT(details_tc_meta);
+       BT_ASSERT_DBG(details_tc_meta);
        need_to_write =
-               g_hash_table_lookup(details_tc_meta->objects, obj) == NULL;
+               !g_hash_table_lookup(details_tc_meta->objects, obj);
 
 end:
        return need_to_write;
@@ -131,9 +128,9 @@ bool details_need_to_write_trace_class(struct details_write_ctx *ctx,
                goto end;
        }
 
-       BT_ASSERT(ctx->details_comp->meta);
+       BT_ASSERT_DBG(ctx->details_comp->meta);
        details_tc_meta = g_hash_table_lookup(ctx->details_comp->meta, tc);
-       need_to_write = details_tc_meta == NULL;
+       need_to_write = !details_tc_meta;
 
 end:
        return need_to_write;
@@ -193,8 +190,8 @@ int details_trace_unique_id(struct details_write_ctx *ctx,
        int ret = 0;
        struct details_trace *details_trace = NULL;
 
-       BT_ASSERT(unique_id);
-       BT_ASSERT(ctx->details_comp->traces);
+       BT_ASSERT_DBG(unique_id);
+       BT_ASSERT_DBG(ctx->details_comp->traces);
        if (!bt_g_hash_table_contains(ctx->details_comp->traces,
                        trace)) {
                /* Not found: create one */
@@ -235,9 +232,7 @@ error:
        ret = -1;
 
 end:
-       if (details_trace) {
-               g_free(details_trace);
-       }
+       g_free(details_trace);
 
        return ret;
 }
This page took 0.026273 seconds and 4 git commands to generate.