#include <babeltrace/graph/clock-class-priority-map.h>
#include <babeltrace/graph/clock-class-priority-map-internal.h>
#include <babeltrace/graph/notification-event-internal.h>
+#include <babeltrace/types.h>
+#include <stdbool.h>
static
void bt_notification_event_destroy(struct bt_object *obj)
}
static
-bool validate_clock_classes(struct bt_notification_event *notif)
+bt_bool validate_clock_classes(struct bt_notification_event *notif)
{
/*
* For each clock class found in the notification's clock class
* this clock class. Also make sure that those clock classes
* are part of the trace to which the event belongs.
*/
- bool is_valid = true;
+ bt_bool is_valid = BT_TRUE;
+
int trace_cc_count;
int cc_prio_map_cc_count;
size_t cc_prio_map_cc_i, trace_cc_i;
+ struct bt_ctf_clock_value *clock_value = NULL;
+ struct bt_ctf_clock_class *clock_class = NULL;
struct bt_ctf_event_class *event_class = NULL;
struct bt_ctf_stream_class *stream_class = NULL;
struct bt_ctf_trace *trace = NULL;
for (cc_prio_map_cc_i = 0; cc_prio_map_cc_i < cc_prio_map_cc_count;
cc_prio_map_cc_i++) {
- struct bt_ctf_clock_class *clock_class =
+ bt_bool found_in_trace = BT_FALSE;
+
+ clock_class =
bt_clock_class_priority_map_get_clock_class_by_index(
notif->cc_prio_map, cc_prio_map_cc_i);
- struct bt_ctf_clock_value *clock_value;
- bool found_in_trace = false;
-
assert(clock_class);
clock_value = bt_ctf_event_get_clock_value(notif->event,
clock_class);
if (!clock_value) {
- is_valid = false;
+ is_valid = BT_FALSE;
goto end;
}
- bt_put(clock_value);
-
for (trace_cc_i = 0; trace_cc_i < trace_cc_count;
trace_cc_i++) {
struct bt_ctf_clock_class *trace_clock_class =
trace_cc_i);
assert(trace_clock_class);
+ bt_put(trace_clock_class);
if (trace_clock_class == clock_class) {
- found_in_trace = true;
+ found_in_trace = BT_TRUE;
break;
}
}
- bt_put(clock_class);
-
if (!found_in_trace) {
- is_valid = false;
+ is_valid = BT_FALSE;
goto end;
}
+
+ BT_PUT(clock_value);
+ BT_PUT(clock_class);
}
end:
+ bt_put(clock_value);
+ bt_put(clock_class);
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)
{
goto error;
}
+ if (!event_has_trace(event)) {
+ goto error;
+ }
+
notification = g_new0(struct bt_notification_event, 1);
if (!notification) {
goto error;