ir: bt_ctf_event_set_packet(): check for common stream class
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 24 Feb 2016 00:24:23 +0000 (19:24 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 24 Feb 2016 20:26:17 +0000 (15:26 -0500)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
formats/ctf/ir/event.c

index 63769c935b4895279383a5ba236a95beef4c6620..0b49abbef4e4db74cb977f8c42939ad73b9ee23b 100644 (file)
@@ -745,6 +745,8 @@ end:
 int bt_ctf_event_set_packet(struct bt_ctf_event *event,
                struct bt_ctf_packet *packet)
 {
+       struct bt_ctf_stream_class *event_stream_class = NULL;
+       struct bt_ctf_stream_class *packet_stream_class = NULL;
        struct bt_ctf_stream *stream = NULL;
        int ret = 0;
 
@@ -764,7 +766,27 @@ int bt_ctf_event_set_packet(struct bt_ctf_event *event,
                        goto end;
                }
        } else {
-               /* Set the event's parent to the packet's stream */
+               /*
+                * This event is an orphan for the moment: it's not
+                * associated to a stream. If this event's event
+                * class's stream class is the same as the packet's
+                * stream's stream class, then it's okay to make the
+                * packet's stream the parent of this event. Otherwise
+                * it's an error.
+                */
+               event_stream_class =
+                       bt_ctf_event_class_get_stream_class(event->event_class);
+               packet_stream_class =
+                       bt_ctf_stream_get_class(packet->stream);
+
+               assert(event_stream_class);
+               assert(packet_stream_class);
+
+               if (event_stream_class != packet_stream_class) {
+                       ret = -1;
+                       goto end;
+               }
+
                bt_object_set_parent(event, packet->stream);
        }
 
@@ -773,6 +795,8 @@ int bt_ctf_event_set_packet(struct bt_ctf_event *event,
 
 end:
        BT_PUT(stream);
+       BT_PUT(event_stream_class);
+       BT_PUT(packet_stream_class);
 
        return ret;
 }
This page took 0.025388 seconds and 4 git commands to generate.