reftable/record: adapt reftable_record_key() to handle allocation failures

The `reftable_record_key()` function cannot pass any errors to the
caller as it has a `void` return type. Adapt it and its callers such
that we can handle errors and start handling allocation failures.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
This commit is contained in:
Patrick Steinhardt
2024-10-17 06:54:08 +02:00
committed by Taylor Blau
parent e693ccf2c9
commit 4abc8022ff
5 changed files with 47 additions and 22 deletions

View File

@ -249,7 +249,10 @@ static int writer_add_record(struct reftable_writer *w,
struct reftable_buf key = REFTABLE_BUF_INIT;
int err;
reftable_record_key(rec, &key);
err = reftable_record_key(rec, &key);
if (err < 0)
goto done;
if (reftable_buf_cmp(&w->last_key, &key) >= 0) {
err = REFTABLE_API_ERROR;
goto done;