Fix: seek error handling
[babeltrace.git] / lib / iterator.c
index 3dbe878846ab3699af938d2e3a98c202eca8d7b3..f79a1d24c222344c8ff890161af2fcb258c2d2d2 100644 (file)
@@ -177,7 +177,7 @@ int bt_iter_set_pos(struct bt_iter *iter, const struct bt_iter_pos *iter_pos)
        switch (iter_pos->type) {
        case BT_SEEK_RESTORE:
                if (!iter_pos->u.restore)
-                       goto error_arg;
+                       return -EINVAL;
 
                heap_free(iter->stream_heap);
                ret = heap_init(iter->stream_heap, 0, stream_compare);
@@ -225,12 +225,11 @@ int bt_iter_set_pos(struct bt_iter *iter, const struct bt_iter_pos *iter_pos)
                        if (ret)
                                goto error;
                }
+       case BT_SEEK_BEGIN:
+               /* fall-through to seek time of 0 */
        case BT_SEEK_TIME:
                tc = iter->ctx->tc;
 
-               if (!iter_pos->u.seek_time)
-                       goto error_arg;
-
                heap_free(iter->stream_heap);
                ret = heap_init(iter->stream_heap, 0, stream_compare);
                if (ret < 0)
@@ -253,13 +252,11 @@ int bt_iter_set_pos(struct bt_iter *iter, const struct bt_iter_pos *iter_pos)
                return 0;
        default:
                /* not implemented */
-               goto error_arg;
+               return -EINVAL;
        }
 
        return 0;
 
-error_arg:
-       ret = -EINVAL;
 error:
        heap_free(iter->stream_heap);
        if (heap_init(iter->stream_heap, 0, stream_compare) < 0) {
This page took 0.031579 seconds and 4 git commands to generate.