From: Mathieu Desnoyers Date: Fri, 9 Mar 2012 21:06:34 +0000 (-0500) Subject: Fix: seek error handling X-Git-Tag: v1.0.0-pre4~9 X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=7344374e79c2d0f84e6252feb4ea3539c844bf30;p=babeltrace.git Fix: seek error handling - EINVAL should not teardown context. - SEEK_TIME 0 should be allowed. Reported-by: Yannick Brosseau Signed-off-by: Mathieu Desnoyers --- diff --git a/lib/iterator.c b/lib/iterator.c index 3dbe8788..f79a1d24 100644 --- a/lib/iterator.c +++ b/lib/iterator.c @@ -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) {