aboutsummaryrefslogtreecommitdiff
path: root/reftable/reader.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-02-18 10:20:43 +0100
committerJunio C Hamano <gitster@pobox.com>2025-02-18 10:55:36 -0800
commit445f9f4f35c663fb668425f8c8fe0a1d58e1d8c7 (patch)
tree9b3500077174934096236cfea832306cde914485 /reftable/reader.c
parent6f6127decde6785b9ba5f22a07a7754d1fda1a59 (diff)
downloadgit-445f9f4f35c663fb668425f8c8fe0a1d58e1d8c7.tar.xz
reftable: stop using `BUG()` in trivial cases
Stop using `BUG()` in the remaining trivial cases that we still have in the reftable library. Instead of aborting the program, we'll now bubble up a `REFTABLE_API_ERROR` to indicate misuse of the calling conventions. Note that in both `reftable_reader_{inc,dec}ref()` we simply stop calling `BUG()` altogether. The only situation where the counter should be zero is when the structure has already been free'd anyway, so we would run into undefined behaviour regardless of whether we try to abort the program or not. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'reftable/reader.c')
-rw-r--r--reftable/reader.c4
1 files changed, 0 insertions, 4 deletions
diff --git a/reftable/reader.c b/reftable/reader.c
index de6e6dd932..36a5633ede 100644
--- a/reftable/reader.c
+++ b/reftable/reader.c
@@ -677,8 +677,6 @@ done:
void reftable_reader_incref(struct reftable_reader *r)
{
- if (!r->refcount)
- BUG("cannot increment ref counter of dead reader");
r->refcount++;
}
@@ -686,8 +684,6 @@ void reftable_reader_decref(struct reftable_reader *r)
{
if (!r)
return;
- if (!r->refcount)
- BUG("cannot decrement ref counter of dead reader");
if (--r->refcount)
return;
block_source_close(&r->source);