From: Philippe Proulx Date: Tue, 4 Apr 2017 00:23:17 +0000 (-0400) Subject: bt_notification_event_create(): validate and freeze event X-Git-Tag: v2.0.0-pre1~387 X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=80f006028eecfb4c6475828b44620fa6b8a568a5;p=babeltrace.git bt_notification_event_create(): validate and freeze event Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- diff --git a/include/babeltrace/ctf-ir/event-internal.h b/include/babeltrace/ctf-ir/event-internal.h index 85fea18c..c47e61f0 100644 --- a/include/babeltrace/ctf-ir/event-internal.h +++ b/include/babeltrace/ctf-ir/event-internal.h @@ -64,6 +64,14 @@ int bt_ctf_event_serialize(struct bt_ctf_event *event, BT_HIDDEN void bt_ctf_event_freeze(struct bt_ctf_event *event); +BT_HIDDEN +static inline struct bt_ctf_packet *bt_ctf_event_borrow_packet( + struct bt_ctf_event *event) +{ + assert(event); + return event->packet; +} + static inline struct bt_ctf_event_class *bt_ctf_event_borrow_event_class( struct bt_ctf_event *event) diff --git a/lib/component/notification/event.c b/lib/component/notification/event.c index c3c461a1..bae1912f 100644 --- a/lib/component/notification/event.c +++ b/lib/component/notification/event.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -94,14 +95,16 @@ end: struct bt_notification *bt_notification_event_create(struct bt_ctf_event *event, struct bt_clock_class_priority_map *cc_prio_map) { - struct bt_notification_event *notification; + struct bt_notification_event *notification = NULL; if (!event || !cc_prio_map) { goto error; } - // FIXME - Validate that the event is associated to a packet - // and freeze the event. + if (!bt_ctf_event_borrow_packet(event)) { + goto error; + } + notification = g_new0(struct bt_notification_event, 1); if (!notification) { goto error; @@ -111,14 +114,14 @@ struct bt_notification *bt_notification_event_create(struct bt_ctf_event *event, bt_notification_event_destroy); notification->event = bt_get(event); notification->cc_prio_map = bt_get(cc_prio_map); - if (!validate_clock_classes(notification)) { - bt_put(notification); goto error; } + bt_ctf_event_freeze(notification->event); return ¬ification->parent; error: + bt_put(notification); return NULL; }