X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=formats%2Fctf%2Fctf.c;h=f078735c3ea9fd5307c46333b28b2c473867a7e1;hp=23a2179bbf19851bb4685143df0c3301a4e2959d;hb=5f643ed7d0d2d21d3797938e34735ef8f1bd9186;hpb=0293560ca8732a9958d26fa9d2c7e978ebf1d8ad diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c index 23a2179b..f078735c 100644 --- a/formats/ctf/ctf.c +++ b/formats/ctf/ctf.c @@ -125,8 +125,11 @@ int ctf_read_event(struct stream_pos *ppos, struct ctf_stream *stream) uint64_t id = 0; int ret; + ctf_pos_get_event(pos); + if (pos->offset == EOF) return EOF; + assert(pos->offset < pos->content_size); /* Read event header */ if (stream->stream_event_header) { @@ -390,8 +393,11 @@ void ctf_move_pos_slow(struct ctf_stream_pos *pos, size_t offset, int whence) assert(off >= 0); pos->offset = 0; } else { + read_next_packet: switch (whence) { case SEEK_CUR: + if (pos->offset == EOF) + return; /* The reader will expect us to skip padding */ assert(pos->offset + offset == pos->content_size); ++pos->cur_index; @@ -415,8 +421,13 @@ void ctf_move_pos_slow(struct ctf_stream_pos *pos, size_t offset, int whence) file_stream->parent.timestamp = index->timestamp_begin; pos->content_size = index->content_size; pos->packet_size = index->packet_size; - if (index->data_offset <= index->content_size) { + if (index->data_offset < index->content_size) { pos->offset = 0; /* will read headers */ + } else if (index->data_offset == index->content_size) { + /* empty packet */ + pos->offset = index->data_offset; + offset = 0; + goto read_next_packet; } else { pos->offset = EOF; return;