reftable/writer: improve error when passed an invalid block size
The reftable format only supports block sizes up to 16MB. When the writer is being passed a value bigger than that it simply calls abort(3P), which isn't all that helpful due to the lack of a proper error message. Improve this by calling `BUG()` instead. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
May 13, 2024 at 10:18 UTC
c22d75b02784baa1713e0c007fcd0cb675dd9f43
1 file changed
+2
-4
reftable/writer.c
+2
-4
@@ -128,10 +128,8 @@ reftable_new_writer(ssize_t (*writer_func)(void *, const void *, size_t),
128
if (_opts)
129
opts = *_opts;
130
options_set_defaults(&opts);
131
- if (opts.block_size >= (1 << 24)) {
132
- /* TODO - error return? */
133
- abort();
134
- }
131
+ if (opts.block_size >= (1 << 24))
132
+ BUG("configured block size exceeds 16MB");
133
134
strbuf_init(&wp->block_writer_data.last_key, 0);
135
strbuf_init(&wp->last_key, 0);