diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-02-01 08:52:00 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-02-01 11:11:32 -0800 |
commit | 9ebb2d7b08c9f17a846b7c90082c9d15b9f6c9d2 (patch) | |
tree | 5c7d1228fc3cac48a657ab31c37f355e1701f90d /reftable | |
parent | d55fc5128b26a64c2e7b6612d0442c9e924696e8 (diff) | |
download | git-9ebb2d7b08c9f17a846b7c90082c9d15b9f6c9d2.tar.gz |
reftable/writer: use correct type to iterate through index entries
The reftable writer is tracking the number of blocks it has to index via
the `index_len` variable. But while this variable is of type `size_t`,
some sites use an `int` to loop through the index entries.
Convert the code to consistently use `size_t`.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'reftable')
-rw-r--r-- | reftable/writer.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/reftable/writer.c b/reftable/writer.c index 92935baa70..5a0b87b406 100644 --- a/reftable/writer.c +++ b/reftable/writer.c @@ -379,20 +379,21 @@ int reftable_writer_add_logs(struct reftable_writer *w, static int writer_finish_section(struct reftable_writer *w) { + struct reftable_block_stats *bstats = NULL; uint8_t typ = block_writer_type(w->block_writer); uint64_t index_start = 0; int max_level = 0; - int threshold = w->opts.unpadded ? 1 : 3; + size_t threshold = w->opts.unpadded ? 1 : 3; int before_blocks = w->stats.idx_stats.blocks; - int err = writer_flush_block(w); - int i = 0; - struct reftable_block_stats *bstats = NULL; + int err; + + err = writer_flush_block(w); if (err < 0) return err; while (w->index_len > threshold) { struct reftable_index_record *idx = NULL; - int idx_len = 0; + size_t i, idx_len; max_level++; index_start = w->next; @@ -630,11 +631,8 @@ done: static void writer_clear_index(struct reftable_writer *w) { - int i = 0; - for (i = 0; i < w->index_len; i++) { + for (size_t i = 0; i < w->index_len; i++) strbuf_release(&w->index[i].last_key); - } - FREE_AND_NULL(w->index); w->index_len = 0; w->index_cap = 0; |