diff options
| author | Patrick Steinhardt <ps@pks.im> | 2025-02-18 10:20:41 +0100 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-02-18 10:55:36 -0800 |
| commit | 9d9fac0f34ec47cc6eafeb3e10378ab8f3310346 (patch) | |
| tree | 2dcef8922bd24884fcda6856291dc32ecbdfd081 /reftable/record.c | |
| parent | a967966432f25324c79524c0cb18d6e152d0b6af (diff) | |
| download | git-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/record.c')
| -rw-r--r-- | reftable/record.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/reftable/record.c b/reftable/record.c index 2c0cc32cbd..1e18f8dffb 100644 --- a/reftable/record.c +++ b/reftable/record.c @@ -1306,7 +1306,7 @@ reftable_record_vtable(struct reftable_record *rec) abort(); } -void reftable_record_init(struct reftable_record *rec, uint8_t typ) +int reftable_record_init(struct reftable_record *rec, uint8_t typ) { memset(rec, 0, sizeof(*rec)); rec->type = typ; @@ -1315,11 +1315,11 @@ void reftable_record_init(struct reftable_record *rec, uint8_t typ) case BLOCK_TYPE_REF: case BLOCK_TYPE_LOG: case BLOCK_TYPE_OBJ: - return; + return 0; case BLOCK_TYPE_INDEX: reftable_buf_init(&rec->u.idx.last_key); - return; + return 0; default: - BUG("unhandled record type"); + return REFTABLE_API_ERROR; } } |
