summaryrefslogtreecommitdiff
path: root/t/unit-tests
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-10-02 12:56:19 +0200
committerJunio C Hamano <gitster@pobox.com>2024-10-02 07:53:55 -0700
commit2d5dbb37b284e3ca78137ec0f8a3d9ceef78877c (patch)
treedebe5c06871bcf2648fd5de1d018d31d1df9ce67 /t/unit-tests
parentcd6a47167e068812735950b841c7174cd7cd321e (diff)
reftable/block: handle allocation failures
Handle allocation failures in `block_writer_init()` and `block_reader_init()`. This requires us to bubble up error codes into `writer_reinit_block_writer()`. Adapt call sites accordingly. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/unit-tests')
-rw-r--r--t/unit-tests/t-reftable-block.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/t/unit-tests/t-reftable-block.c b/t/unit-tests/t-reftable-block.c
index f1a49485e2..e52a612e85 100644
--- a/t/unit-tests/t-reftable-block.c
+++ b/t/unit-tests/t-reftable-block.c
@@ -34,8 +34,9 @@ static void t_ref_block_read_write(void)
REFTABLE_CALLOC_ARRAY(block.data, block_size);
block.len = block_size;
block_source_from_strbuf(&block.source ,&buf);
- block_writer_init(&bw, BLOCK_TYPE_REF, block.data, block_size,
- header_off, hash_size(GIT_SHA1_FORMAT_ID));
+ ret = block_writer_init(&bw, BLOCK_TYPE_REF, block.data, block_size,
+ header_off, hash_size(GIT_SHA1_FORMAT_ID));
+ check(!ret);
rec.u.ref.refname = (char *) "";
rec.u.ref.value_type = REFTABLE_REF_DELETION;
@@ -126,8 +127,9 @@ static void t_log_block_read_write(void)
REFTABLE_CALLOC_ARRAY(block.data, block_size);
block.len = block_size;
block_source_from_strbuf(&block.source ,&buf);
- block_writer_init(&bw, BLOCK_TYPE_LOG, block.data, block_size,
- header_off, hash_size(GIT_SHA1_FORMAT_ID));
+ ret = block_writer_init(&bw, BLOCK_TYPE_LOG, block.data, block_size,
+ header_off, hash_size(GIT_SHA1_FORMAT_ID));
+ check(!ret);
for (i = 0; i < N; i++) {
rec.u.log.refname = xstrfmt("branch%02"PRIuMAX , (uintmax_t)i);
@@ -214,8 +216,9 @@ static void t_obj_block_read_write(void)
REFTABLE_CALLOC_ARRAY(block.data, block_size);
block.len = block_size;
block_source_from_strbuf(&block.source, &buf);
- block_writer_init(&bw, BLOCK_TYPE_OBJ, block.data, block_size,
- header_off, hash_size(GIT_SHA1_FORMAT_ID));
+ ret = block_writer_init(&bw, BLOCK_TYPE_OBJ, block.data, block_size,
+ header_off, hash_size(GIT_SHA1_FORMAT_ID));
+ check(!ret);
for (i = 0; i < N; i++) {
uint8_t bytes[] = { i, i + 1, i + 2, i + 3, i + 5 }, *allocated;
@@ -296,8 +299,9 @@ static void t_index_block_read_write(void)
REFTABLE_CALLOC_ARRAY(block.data, block_size);
block.len = block_size;
block_source_from_strbuf(&block.source, &buf);
- block_writer_init(&bw, BLOCK_TYPE_INDEX, block.data, block_size,
- header_off, hash_size(GIT_SHA1_FORMAT_ID));
+ ret = block_writer_init(&bw, BLOCK_TYPE_INDEX, block.data, block_size,
+ header_off, hash_size(GIT_SHA1_FORMAT_ID));
+ check(!ret);
for (i = 0; i < N; i++) {
strbuf_init(&recs[i].u.idx.last_key, 9);