Add internal BT_ASSERT() and BT_ASSERT_PRE() helpers
[babeltrace.git] / lib / graph / notification / inactivity.c
index 9a01b7cc95b3fbd7f3c7126bdd964320d810fbbf..118b18d6e7e4d32eeff3d32542af5988681389e7 100644 (file)
@@ -55,9 +55,15 @@ struct bt_notification *bt_notification_inactivity_create(
        struct bt_notification_inactivity *notification;
        struct bt_notification *ret_notif = NULL;
 
-       if (!cc_prio_map) {
-               BT_LOGW_STR("Invalid parameter: clock class priority map is NULL.");
-               goto error;
+       if (cc_prio_map) {
+               /* Function's reference, released at the end */
+               bt_get(cc_prio_map);
+       } else {
+               cc_prio_map = bt_clock_class_priority_map_create();
+               if (!cc_prio_map) {
+                       BT_LOGE_STR("Cannot create empty clock class priority map.");
+                       goto error;
+               }
        }
 
        BT_LOGD("Creating inactivity notification object: "
@@ -91,6 +97,7 @@ error:
        BT_PUT(ret_notif);
 
 end:
+       bt_put(cc_prio_map);
        return ret_notif;
 }
 
@@ -122,11 +129,11 @@ end:
        return cc_prio_map;
 }
 
-struct bt_ctf_clock_value *bt_notification_inactivity_get_clock_value(
+struct bt_clock_value *bt_notification_inactivity_get_clock_value(
                struct bt_notification *notification,
-               struct bt_ctf_clock_class *clock_class)
+               struct bt_clock_class *clock_class)
 {
-       struct bt_ctf_clock_value *clock_value = NULL;
+       struct bt_clock_value *clock_value = NULL;
        struct bt_notification_inactivity *inactivity_notification;
 
        if (!notification) {
@@ -160,11 +167,11 @@ end:
 
 int bt_notification_inactivity_set_clock_value(
                struct bt_notification *notification,
-               struct bt_ctf_clock_value *clock_value)
+               struct bt_clock_value *clock_value)
 {
        int ret = 0;
        uint64_t prio;
-       struct bt_ctf_clock_class *clock_class = NULL;
+       struct bt_clock_class *clock_class = NULL;
        struct bt_notification_inactivity *inactivity_notification;
 
        if (!notification) {
@@ -191,12 +198,13 @@ int bt_notification_inactivity_set_clock_value(
                        "addr%p, notif-type=%s",
                        notification, bt_notification_type_string(
                                bt_notification_get_type(notification)));
+               ret = -1;
                goto end;
        }
 
        inactivity_notification = container_of(notification,
                        struct bt_notification_inactivity, parent);
-       clock_class = bt_ctf_clock_value_get_class(clock_value);
+       clock_class = bt_clock_value_get_class(clock_value);
        ret = bt_clock_class_priority_map_get_clock_class_priority(
                inactivity_notification->cc_prio_map, clock_class, &prio);
        if (ret) {
@@ -206,8 +214,9 @@ int bt_notification_inactivity_set_clock_value(
                        "clock-value-addr=%p",
                        inactivity_notification,
                        inactivity_notification->cc_prio_map,
-                       clock_class, bt_ctf_clock_class_get_name(clock_class),
+                       clock_class, bt_clock_class_get_name(clock_class),
                        clock_value);
+               ret = -1;
                goto end;
        }
 
@@ -220,7 +229,7 @@ int bt_notification_inactivity_set_clock_value(
                "clock-value-addr=%p",
                inactivity_notification,
                inactivity_notification->cc_prio_map,
-               clock_class, bt_ctf_clock_class_get_name(clock_class),
+               clock_class, bt_clock_class_get_name(clock_class),
                clock_value);
 
 end:
This page took 0.024314 seconds and 4 git commands to generate.