X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=plugins%2Futils%2Ftrimmer%2Ftrimmer.c;h=4d52e22e08b394d09fe14b615583d757b38cfc93;hb=0cbc2c3316814e4b4bf3fd3ba3b361b165949e95;hp=d9407bfda205e1341f8d3ed4186eab2bf0c30d7f;hpb=fdd3a2da18afef5ca32ba181a8b6ebbff173df02;p=babeltrace.git diff --git a/plugins/utils/trimmer/trimmer.c b/plugins/utils/trimmer/trimmer.c index d9407bfd..4d52e22e 100644 --- a/plugins/utils/trimmer/trimmer.c +++ b/plugins/utils/trimmer/trimmer.c @@ -620,7 +620,6 @@ int get_msg_ns_from_origin(const bt_message *msg, int64_t *ns_from_origin, { const bt_clock_class *clock_class = NULL; const bt_clock_snapshot *clock_snapshot = NULL; - bt_clock_snapshot_state cs_state = BT_CLOCK_SNAPSHOT_STATE_KNOWN; bt_message_stream_activity_clock_snapshot_state sa_cs_state; int ret = 0; @@ -637,8 +636,8 @@ int get_msg_ns_from_origin(const bt_message *msg, int64_t *ns_from_origin, goto error; } - cs_state = bt_message_event_borrow_default_clock_snapshot_const( - msg, &clock_snapshot); + clock_snapshot = bt_message_event_borrow_default_clock_snapshot_const( + msg); break; case BT_MESSAGE_TYPE_PACKET_BEGINNING: clock_class = @@ -648,8 +647,8 @@ int get_msg_ns_from_origin(const bt_message *msg, int64_t *ns_from_origin, goto error; } - cs_state = bt_message_packet_beginning_borrow_default_clock_snapshot_const( - msg, &clock_snapshot); + clock_snapshot = bt_message_packet_beginning_borrow_default_clock_snapshot_const( + msg); break; case BT_MESSAGE_TYPE_PACKET_END: clock_class = @@ -659,8 +658,8 @@ int get_msg_ns_from_origin(const bt_message *msg, int64_t *ns_from_origin, goto error; } - cs_state = bt_message_packet_end_borrow_default_clock_snapshot_const( - msg, &clock_snapshot); + clock_snapshot = bt_message_packet_end_borrow_default_clock_snapshot_const( + msg); break; case BT_MESSAGE_TYPE_DISCARDED_EVENTS: clock_class = @@ -670,8 +669,8 @@ int get_msg_ns_from_origin(const bt_message *msg, int64_t *ns_from_origin, goto error; } - cs_state = bt_message_discarded_events_borrow_default_beginning_clock_snapshot_const( - msg, &clock_snapshot); + clock_snapshot = bt_message_discarded_events_borrow_default_beginning_clock_snapshot_const( + msg); break; case BT_MESSAGE_TYPE_DISCARDED_PACKETS: clock_class = @@ -681,8 +680,8 @@ int get_msg_ns_from_origin(const bt_message *msg, int64_t *ns_from_origin, goto error; } - cs_state = bt_message_discarded_packets_borrow_default_beginning_clock_snapshot_const( - msg, &clock_snapshot); + clock_snapshot = bt_message_discarded_packets_borrow_default_beginning_clock_snapshot_const( + msg); break; case BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING: clock_class = @@ -724,20 +723,14 @@ int get_msg_ns_from_origin(const bt_message *msg, int64_t *ns_from_origin, break; case BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY: - cs_state = + clock_snapshot = bt_message_message_iterator_inactivity_borrow_default_clock_snapshot_const( - msg, &clock_snapshot); + msg); break; default: goto no_clock_snapshot; } - if (unlikely(cs_state != BT_CLOCK_SNAPSHOT_STATE_KNOWN)) { - BT_LOGE_STR("Unsupported unknown clock snapshot."); - ret = -1; - goto end; - } - ret = bt_clock_snapshot_get_ns_from_origin(clock_snapshot, ns_from_origin); if (unlikely(ret)) { @@ -896,7 +889,7 @@ bt_self_message_iterator_status state_seek_initially( if (!bt_self_component_port_input_message_iterator_can_seek_beginning( trimmer_it->upstream_iter)) { BT_LOGE_STR("Cannot make upstream message iterator initially seek its beginning."); - status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; goto end; } @@ -909,7 +902,7 @@ bt_self_message_iterator_status state_seek_initially( BT_LOGE("Cannot make upstream message iterator initially seek: " "seek-ns-from-origin=%" PRId64, trimmer_it->begin.ns_from_origin); - status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK; + status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; goto end; } @@ -1116,15 +1109,16 @@ bt_self_message_iterator_status create_stream_beginning_activity_message( const bt_stream *stream, const bt_clock_class *clock_class, bt_message **msg) { + bt_message *local_msg; bt_self_message_iterator_status status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK; BT_ASSERT(msg); BT_ASSERT(!trimmer_it->begin.is_infinite); - *msg = bt_message_stream_activity_beginning_create( + local_msg = bt_message_stream_activity_beginning_create( trimmer_it->self_msg_iter, stream); - if (!*msg) { + if (!local_msg) { status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM; goto end; } @@ -1137,14 +1131,16 @@ bt_self_message_iterator_status create_stream_beginning_activity_message( trimmer_it->begin.ns_from_origin, &raw_value); if (ret) { status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; - bt_message_put_ref(*msg); + bt_message_put_ref(local_msg); goto end; } bt_message_stream_activity_beginning_set_default_clock_snapshot( - *msg, raw_value); + local_msg, raw_value); } + BT_MESSAGE_MOVE_REF(*msg, local_msg); + end: return status; } @@ -1428,16 +1424,16 @@ bt_self_message_iterator_status handle_message_with_stream_state( * know there's a default clock and it's always * known. */ - (void) bt_message_discarded_events_borrow_default_end_clock_snapshot_const( - msg, &end_cs); + end_cs = bt_message_discarded_events_borrow_default_end_clock_snapshot_const( + msg); } else { /* * Safe to ignore the return value because we * know there's a default clock and it's always * known. */ - (void) bt_message_discarded_packets_borrow_default_end_clock_snapshot_const( - msg, &end_cs); + end_cs = bt_message_discarded_packets_borrow_default_end_clock_snapshot_const( + msg); } if (bt_clock_snapshot_get_ns_from_origin(end_cs, @@ -1479,16 +1475,16 @@ bt_self_message_iterator_status handle_message_with_stream_state( } if (msg_type == BT_MESSAGE_TYPE_DISCARDED_EVENTS) { - (void) bt_message_discarded_events_borrow_default_beginning_clock_snapshot_const( - msg, &begin_cs); + begin_cs = bt_message_discarded_events_borrow_default_beginning_clock_snapshot_const( + msg); new_msg = bt_message_discarded_events_create_with_default_clock_snapshots( trimmer_it->self_msg_iter, sstate->stream, bt_clock_snapshot_get_value(begin_cs), end_raw_value); } else { - (void) bt_message_discarded_packets_borrow_default_beginning_clock_snapshot_const( - msg, &begin_cs); + begin_cs = bt_message_discarded_packets_borrow_default_beginning_clock_snapshot_const( + msg); new_msg = bt_message_discarded_packets_create_with_default_clock_snapshots( trimmer_it->self_msg_iter, sstate->stream, @@ -1737,18 +1733,6 @@ bt_self_message_iterator_status handle_message( goto end; } - if (!bt_stream_class_default_clock_is_always_known(sc)) { - BT_LOGE("Unsupported stream: clock does not " - "always have a known value: " - "stream-addr=%p, " - "stream-id=%" PRIu64 ", " - "stream-name=\"%s\"", - stream, bt_stream_get_id(stream), - bt_stream_get_name(stream)); - status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR; - goto end; - } - sstate = g_new0(struct trimmer_iterator_stream_state, 1); if (!sstate) {