Skip to content

Commit df52104

Browse files
committed
reftable tests: check reftable_table_init_ref_iterator() return
test_reftable_table__seek_once() and test_reftable_table__reseek() both call reftable_table_init_ref_iterator() without checking its return value. This function returns an int error code (0 on success, negative on failure). Every other reftable function call in these same tests checks the return via cl_assert_equal_i() or cl_assert(), making this omission inconsistent. If the iterator initialization ever fails (e.g., due to a memory allocation failure in the reftable internals), the test would proceed to seek and read with an uninitialized iterator, producing misleading test results or crashes rather than a clear assertion failure. Check the return value via cl_assert_equal_i(ret, 0), consistent with the surrounding code. Pointed out by Coverity. Assisted-by: Claude Opus 4.6 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 712186b commit df52104

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

t/unit-tests/u-reftable-table.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ void test_reftable_table__seek_once(void)
2828
ret = reftable_table_new(&table, &source, "name");
2929
cl_assert(!ret);
3030

31-
reftable_table_init_ref_iterator(table, &it);
31+
ret = reftable_table_init_ref_iterator(table, &it);
32+
cl_assert_equal_i(ret, 0);
3233
ret = reftable_iterator_seek_ref(&it, "");
3334
cl_assert(!ret);
3435
ret = reftable_iterator_next_ref(&it, &ref);
@@ -70,7 +71,8 @@ void test_reftable_table__reseek(void)
7071
ret = reftable_table_new(&table, &source, "name");
7172
cl_assert(!ret);
7273

73-
reftable_table_init_ref_iterator(table, &it);
74+
ret = reftable_table_init_ref_iterator(table, &it);
75+
cl_assert_equal_i(ret, 0);
7476

7577
for (size_t i = 0; i < 5; i++) {
7678
ret = reftable_iterator_seek_ref(&it, "");

0 commit comments

Comments
 (0)