X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=formats%2Fctf%2Fctf.c;h=ea760f0e0725aecf7d53e719e8492374834b0491;hb=1059a2bfb89dfcdea336d7fdd5ef9bbdf552f3f2;hp=80bd37869ed897f947c1b99e3f871b3d93d9692d;hpb=25ccc85ba8fce5fb8402f1c6fc63a75ff7f07d99;p=babeltrace.git diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c index 80bd3786..ea760f0e 100644 --- a/formats/ctf/ctf.c +++ b/formats/ctf/ctf.c @@ -229,6 +229,11 @@ int ctf_read_event(struct stream_pos *ppos, struct ctf_stream *stream) ctf_pos_get_event(pos); + /* save the current position as a restore point */ + pos->last_offset = pos->offset; + /* we just read the event, it is consumed when used by the caller */ + stream->consumed = 0; + /* * This is the EOF check after we've advanced the position in * ctf_pos_get_event. @@ -507,8 +512,8 @@ void ctf_move_pos_slow(struct ctf_stream_pos *pos, size_t offset, int whence) break; } case SEEK_SET: - assert(offset == 0); /* only seek supported for now */ - pos->cur_index = 0; + if (offset == 0) + pos->cur_index = 0; file_stream->parent.prev_timestamp = 0; file_stream->parent.prev_timestamp_end = 0; break; @@ -1180,14 +1185,14 @@ int create_stream_packet_index(struct ctf_trace *td, /* Validate content size and packet size values */ if (packet_index.content_size > packet_index.packet_size) { - fprintf(stderr, "[error] Content size (%zu bits) is larger than packet size (%zu bits).\n", + fprintf(stderr, "[error] Content size (%" PRIu64 " bits) is larger than packet size (%" PRIu64 " bits).\n", packet_index.content_size, packet_index.packet_size); return -EINVAL; } - if (packet_index.packet_size > (filestats.st_size - packet_index.offset) * CHAR_BIT) { - fprintf(stderr, "[error] Packet size (%zu bits) is larger than remaining file size (%zu bits).\n", - packet_index.content_size, (size_t) (filestats.st_size - packet_index.offset) * CHAR_BIT); + if (packet_index.packet_size > ((uint64_t)filestats.st_size - packet_index.offset) * CHAR_BIT) { + fprintf(stderr, "[error] Packet size (%" PRIu64 " bits) is larger than remaining file size (%" PRIu64 " bits).\n", + packet_index.content_size, ((uint64_t)filestats.st_size - packet_index.offset) * CHAR_BIT); return -EINVAL; }