X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Flib%2Ftrace-ir%2Fclock-snapshot.c;h=29b248e95c64f53451f1fe1f9edfe517a8934bbe;hb=5faa71312312b1ed13dcb7487979fa73fed736d7;hp=6b44334e914c1d289ce87a0a1bdb8afd23df37dc;hpb=350ad6c1c5f45a4e90c33e3c1354125c209bbf02;p=babeltrace.git diff --git a/src/lib/trace-ir/clock-snapshot.c b/src/lib/trace-ir/clock-snapshot.c index 6b44334e..29b248e9 100644 --- a/src/lib/trace-ir/clock-snapshot.c +++ b/src/lib/trace-ir/clock-snapshot.c @@ -21,10 +21,10 @@ */ #define BT_LOG_TAG "LIB/CLOCK-SNAPSHOT" -#include "lib/lib-logging.h" +#include "lib/logging.h" #include "lib/assert-pre.h" -#include "compat/uuid.h" +#include "common/uuid.h" #include "clock-class.h" #include "clock-snapshot.h" #include @@ -34,10 +34,12 @@ #include #include "lib/object.h" #include "common/assert.h" +#include "lib/func-status.h" BT_HIDDEN void bt_clock_snapshot_destroy(struct bt_clock_snapshot *clock_snapshot) { + BT_ASSERT(clock_snapshot); BT_LIB_LOGD("Destroying clock snapshot: %!+k", clock_snapshot); BT_OBJECT_PUT_REF_AND_RESET(clock_snapshot->clock_class); g_free(clock_snapshot); @@ -54,7 +56,8 @@ struct bt_clock_snapshot *bt_clock_snapshot_new( clock_class); ret = g_new0(struct bt_clock_snapshot, 1); if (!ret) { - BT_LOGE_STR("Failed to allocate one clock snapshot."); + BT_LIB_LOGE_APPEND_CAUSE( + "Failed to allocate one clock snapshot."); goto end; } @@ -77,9 +80,10 @@ struct bt_clock_snapshot *bt_clock_snapshot_create( BT_ASSERT(clock_class); clock_snapshot = bt_object_pool_create_object(&clock_class->cs_pool); if (!clock_snapshot) { - BT_LIB_LOGE("Cannot allocate one clock snapshot from clock class's clock snapshot pool: " + BT_LIB_LOGE_APPEND_CAUSE( + "Cannot allocate one clock snapshot from clock class's clock snapshot pool: " "%![cc-]+K", clock_class); - goto error; + goto end; } if (G_LIKELY(!clock_snapshot->clock_class)) { @@ -87,14 +91,6 @@ struct bt_clock_snapshot *bt_clock_snapshot_create( bt_object_get_no_null_check(clock_class); } - goto end; - -error: - if (clock_snapshot) { - bt_clock_snapshot_recycle(clock_snapshot); - clock_snapshot = NULL; - } - end: return clock_snapshot; } @@ -140,28 +136,30 @@ void bt_clock_snapshot_recycle(struct bt_clock_snapshot *clock_snapshot) uint64_t bt_clock_snapshot_get_value( const struct bt_clock_snapshot *clock_snapshot) { - BT_ASSERT_PRE_NON_NULL(clock_snapshot, "Clock snapshot"); - BT_ASSERT_PRE(clock_snapshot->is_set, + BT_ASSERT_PRE_DEV_NON_NULL(clock_snapshot, "Clock snapshot"); + BT_ASSERT_PRE_DEV(clock_snapshot->is_set, "Clock snapshot is not set: %!+k", clock_snapshot); return clock_snapshot->value_cycles; } -enum bt_clock_snapshot_status bt_clock_snapshot_get_ns_from_origin( +enum bt_clock_snapshot_get_ns_from_origin_status +bt_clock_snapshot_get_ns_from_origin( const struct bt_clock_snapshot *clock_snapshot, int64_t *ret_value_ns) { - int ret = BT_CLOCK_SNAPSHOT_STATUS_OK; + int ret = BT_FUNC_STATUS_OK; - BT_ASSERT_PRE_NON_NULL(clock_snapshot, "Clock snapshot"); - BT_ASSERT_PRE_NON_NULL(ret_value_ns, "Value (ns) (output)"); - BT_ASSERT_PRE(clock_snapshot->is_set, + BT_ASSERT_PRE_DEV_NON_NULL(clock_snapshot, "Clock snapshot"); + BT_ASSERT_PRE_DEV_NON_NULL(ret_value_ns, "Value (ns) (output)"); + BT_ASSERT_PRE_DEV(clock_snapshot->is_set, "Clock snapshot is not set: %!+k", clock_snapshot); if (clock_snapshot->ns_from_origin_overflows) { - BT_LIB_LOGD("Clock snapshot, once converted to nanoseconds from origin, " + BT_LIB_LOGE_APPEND_CAUSE( + "Clock snapshot, once converted to nanoseconds from origin, " "overflows the signed 64-bit integer range: " "%![cs-]+k", clock_snapshot); - ret = BT_CLOCK_SNAPSHOT_STATUS_OVERFLOW; + ret = BT_FUNC_STATUS_OVERFLOW_ERROR; goto end; } @@ -174,6 +172,6 @@ end: const struct bt_clock_class *bt_clock_snapshot_borrow_clock_class_const( const struct bt_clock_snapshot *clock_snapshot) { - BT_ASSERT_PRE_NON_NULL(clock_snapshot, "Clock snapshot"); + BT_ASSERT_PRE_DEV_NON_NULL(clock_snapshot, "Clock snapshot"); return clock_snapshot->clock_class; }