aboutsummaryrefslogtreecommitdiff
path: root/reftable/block.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-02-18 10:20:41 +0100
committerJunio C Hamano <gitster@pobox.com>2025-02-18 10:55:36 -0800
commit9d9fac0f34ec47cc6eafeb3e10378ab8f3310346 (patch)
tree2dcef8922bd24884fcda6856291dc32ecbdfd081 /reftable/block.c
parenta967966432f25324c79524c0cb18d6e152d0b6af (diff)
downloadgit-9d9fac0f34ec47cc6eafeb3e10378ab8f3310346.tar.xz
reftable/record: stop using `BUG()` in `reftable_record_init()`
We're aborting the program via `BUG()` in case `reftable_record_init()` was invoked with an unknown record type. This is bad because we may now die in library code, and because it makes us depend on the Git codebase. Refactor the code such that `reftable_record_init()` can return an error code to the caller. Adapt any callers accordingly. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'reftable/block.c')
-rw-r--r--reftable/block.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/reftable/block.c b/reftable/block.c
index b14a8f1259..999876826d 100644
--- a/reftable/block.c
+++ b/reftable/block.c
@@ -508,7 +508,9 @@ int block_iter_seek_key(struct block_iter *it, const struct block_reader *br,
it->block_len = br->block_len;
it->hash_size = br->hash_size;
- reftable_record_init(&rec, block_reader_type(br));
+ err = reftable_record_init(&rec, block_reader_type(br));
+ if (err < 0)
+ goto done;
/*
* We're looking for the last entry less than the wanted key so that