summaryrefslogtreecommitdiff
path: root/reftable/block_test.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2022-02-16 15:14:27 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2022-02-16 15:14:28 -0800
commit34230514b83f55ea0f4531e8486533ac5c3e2ffe (patch)
treef1c51b9380a93f2d6abdb9ab25489faedbe59c93 /reftable/block_test.c
parentMerge branch 'll/doc-mktree-typofix' (diff)
parentreftable: add print functions to the record types (diff)
downloadtgif-34230514b83f55ea0f4531e8486533ac5c3e2ffe.tar.xz
Merge branch 'hn/reftable-coverity-fixes'
Problems identified by Coverity in the reftable code have been corrected. * hn/reftable-coverity-fixes: reftable: add print functions to the record types reftable: make reftable_record a tagged union reftable: remove outdated file reftable.c reftable: implement record equality generically reftable: make reftable-record.h function signatures const correct reftable: handle null refnames in reftable_ref_record_equal reftable: drop stray printf in readwrite_test reftable: order unittests by complexity reftable: all xxx_free() functions accept NULL arguments reftable: fix resource warning reftable: ignore remove() return value in stack_test.c reftable: check reftable_stack_auto_compact() return value reftable: fix resource leak blocksource.c reftable: fix resource leak in block.c error path reftable: fix OOB stack write in print functions
Diffstat (limited to 'reftable/block_test.c')
-rw-r--r--reftable/block_test.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/reftable/block_test.c b/reftable/block_test.c
index 4b3ea262dc..fa2ee092ec 100644
--- a/reftable/block_test.c
+++ b/reftable/block_test.c
@@ -26,8 +26,9 @@ static void test_block_read_write(void)
struct block_writer bw = {
.last_key = STRBUF_INIT,
};
- struct reftable_ref_record ref = { NULL };
- struct reftable_record rec = { NULL };
+ struct reftable_record rec = {
+ .type = BLOCK_TYPE_REF,
+ };
int i = 0;
int n;
struct block_reader br = { 0 };
@@ -40,7 +41,6 @@ static void test_block_read_write(void)
block.source = malloc_block_source();
block_writer_init(&bw, BLOCK_TYPE_REF, block.data, block_size,
header_off, hash_size(GIT_SHA1_FORMAT_ID));
- reftable_record_from_ref(&rec, &ref);
for (i = 0; i < N; i++) {
char name[100];
@@ -48,14 +48,14 @@ static void test_block_read_write(void)
snprintf(name, sizeof(name), "branch%02d", i);
memset(hash, i, sizeof(hash));
- ref.refname = name;
- ref.value_type = REFTABLE_REF_VAL1;
- ref.value.val1 = hash;
+ rec.u.ref.refname = name;
+ rec.u.ref.value_type = REFTABLE_REF_VAL1;
+ rec.u.ref.value.val1 = hash;
names[i] = xstrdup(name);
n = block_writer_add(&bw, &rec);
- ref.refname = NULL;
- ref.value_type = REFTABLE_REF_DELETION;
+ rec.u.ref.refname = NULL;
+ rec.u.ref.value_type = REFTABLE_REF_DELETION;
EXPECT(n == 0);
}
@@ -74,7 +74,7 @@ static void test_block_read_write(void)
if (r > 0) {
break;
}
- EXPECT_STREQ(names[j], ref.refname);
+ EXPECT_STREQ(names[j], rec.u.ref.refname);
j++;
}
@@ -92,7 +92,7 @@ static void test_block_read_write(void)
n = block_iter_next(&it, &rec);
EXPECT(n == 0);
- EXPECT_STREQ(names[i], ref.refname);
+ EXPECT_STREQ(names[i], rec.u.ref.refname);
want.len--;
n = block_reader_seek(&br, &it, &want);
@@ -100,7 +100,7 @@ static void test_block_read_write(void)
n = block_iter_next(&it, &rec);
EXPECT(n == 0);
- EXPECT_STREQ(names[10 * (i / 10)], ref.refname);
+ EXPECT_STREQ(names[10 * (i / 10)], rec.u.ref.refname);
block_iter_close(&it);
}