Fix: Use the bt_iter_set_pos function to set the begin_pos
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 21 Nov 2013 23:07:20 +0000 (18:07 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 23 Nov 2013 06:07:28 +0000 (01:07 -0500)
The current implementation of bt_iter_init asserts on begin_pos
that are not BT_SEEK_BEGIN. This uses the iterator set_pos function
to achieve the intended behavior.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
lib/iterator.c

index 009fcd3fecf0b502e19a4719225d470fd4719c7d..966a00010e3e82a8393987f72f78b9e4d820c70f 100644 (file)
@@ -702,23 +702,17 @@ int bt_iter_init(struct bt_iter *iter,
                        for (filenr = 0; filenr < stream->streams->len;
                                        filenr++) {
                                struct ctf_file_stream *file_stream;
+                               struct bt_iter_pos pos;
 
                                file_stream = g_ptr_array_index(stream->streams,
                                                filenr);
                                if (!file_stream)
                                        continue;
-                               if (begin_pos) {
-                                       ret = babeltrace_filestream_seek(
-                                                       file_stream,
-                                                       begin_pos,
-                                                       stream_id);
-                               } else {
-                                       struct bt_iter_pos pos;
-                                       pos.type = BT_SEEK_BEGIN;
-                                       ret = babeltrace_filestream_seek(
-                                                       file_stream, &pos,
-                                                       stream_id);
-                               }
+
+                               pos.type = BT_SEEK_BEGIN;
+                               ret = babeltrace_filestream_seek(file_stream,
+                                       &pos, stream_id);
+
                                if (ret == EOF) {
                                        ret = 0;
                                        continue;
@@ -734,7 +728,11 @@ int bt_iter_init(struct bt_iter *iter,
        }
 
        ctx->current_iterator = iter;
-       return 0;
+       if (begin_pos && begin_pos->type != BT_SEEK_BEGIN) {
+               ret = bt_iter_set_pos(iter, begin_pos);
+       }
+
+       return ret;
 
 error:
        bt_heap_free(iter->stream_heap);
This page took 0.034105 seconds and 4 git commands to generate.