diff options
| author | Patrick Steinhardt <ps@pks.im> | 2025-01-20 17:17:25 +0100 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-01-21 14:20:30 -0800 |
| commit | b1e4b6f4dc27481e8c07acc2e7629ae206d25f6c (patch) | |
| tree | 3778e007fb96dec24aaa4c233c2f170ccb4f2b33 | |
| parent | ffe664366890f252ad14e87c987c57e080182bca (diff) | |
| download | git-b1e4b6f4dc27481e8c07acc2e7629ae206d25f6c.tar.gz | |
reftable/block: adjust type of the restart length
The restart length is tracked as a positive integer even though it
cannot ever be negative. Furthermore, it is effectively capped via the
MAX_RESTARTS variable.
Adjust the type of the variable to be `uint32_t`. While this type is
excessive given that MAX_RESTARTS fits into an `uint16_t`, other places
already use 32 bit integers for restarts, so this type is being more
consistent.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
| -rw-r--r-- | reftable/block.c | 12 | ||||
| -rw-r--r-- | reftable/reftable-writer.h | 2 |
2 files changed, 6 insertions, 8 deletions
diff --git a/reftable/block.c b/reftable/block.c index 1275085257..8ac865ce78 100644 --- a/reftable/block.c +++ b/reftable/block.c @@ -40,16 +40,15 @@ size_t footer_size(int version) static int block_writer_register_restart(struct block_writer *w, int n, int is_restart, struct reftable_buf *key) { - int rlen, err; + uint32_t rlen; + int err; rlen = w->restart_len; - if (rlen >= MAX_RESTARTS) { + if (rlen >= MAX_RESTARTS) is_restart = 0; - } - if (is_restart) { + if (is_restart) rlen++; - } if (2 + 3 * rlen + n > w->block_size - w->next) return -1; if (is_restart) { @@ -148,8 +147,7 @@ done: int block_writer_finish(struct block_writer *w) { - int i; - for (i = 0; i < w->restart_len; i++) { + for (uint32_t i = 0; i < w->restart_len; i++) { put_be24(w->block + w->next, w->restarts[i]); w->next += 3; } diff --git a/reftable/reftable-writer.h b/reftable/reftable-writer.h index 5f9afa620b..bfef3b1721 100644 --- a/reftable/reftable-writer.h +++ b/reftable/reftable-writer.h @@ -84,7 +84,7 @@ struct reftable_block_stats { /* total number of entries written */ int entries; /* total number of key restarts */ - int restarts; + uint32_t restarts; /* total number of blocks */ int blocks; /* total number of index blocks */ |
