From a68c0f97106c1b5ef70ec92a3e88e5e830a8b31f Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Thu, 18 May 2017 19:49:53 -0400 Subject: [PATCH] Event notification: make sure contained event has a trace MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Because we need to keep support for legacy CTF writer behaviours, we can still create a "floating" event without its stream class attached to a trace. Disallow the creation of an event notification with such an event to provide the guarantee to filter and sink components that you can always find the trace of an event notification's event. Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- lib/graph/notification/event.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/graph/notification/event.c b/lib/graph/notification/event.c index 8e5d67249..c4474c158 100644 --- a/lib/graph/notification/event.c +++ b/lib/graph/notification/event.c @@ -34,6 +34,7 @@ #include #include #include +#include static void bt_notification_event_destroy(struct bt_object *obj) @@ -120,6 +121,19 @@ end: return is_valid; } +static +bool event_has_trace(struct bt_ctf_event *event) +{ + struct bt_ctf_event_class *event_class; + struct bt_ctf_stream_class *stream_class; + + event_class = bt_ctf_event_borrow_event_class(event); + assert(event_class); + stream_class = bt_ctf_event_class_borrow_stream_class(event_class); + assert(stream_class); + return bt_ctf_stream_class_borrow_trace(stream_class) != NULL; +} + struct bt_notification *bt_notification_event_create(struct bt_ctf_event *event, struct bt_clock_class_priority_map *cc_prio_map) { @@ -133,6 +147,10 @@ struct bt_notification *bt_notification_event_create(struct bt_ctf_event *event, goto error; } + if (!event_has_trace(event)) { + goto error; + } + notification = g_new0(struct bt_notification_event, 1); if (!notification) { goto error; -- 2.34.1