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>

Patrick Steinhardt committed Feb 1, 2024 at 08:52 UTC 9ebb2d7b08c9f17a846b7c90082c9d15b9f6c9d2
1 file changed +7 -9
reftable/writer.c
+7 -9
@@ -379,20 +379,21 @@ int reftable_writer_add_logs(struct reftable_writer *w,
379
380 static int writer_finish_section(struct reftable_writer *w)
381 {
382 + struct reftable_block_stats *bstats = NULL;
383 uint8_t typ = block_writer_type(w->block_writer);
384 uint64_t index_start = 0;
385 int max_level = 0;
385 - int threshold = w->opts.unpadded ? 1 : 3;
386 + size_t threshold = w->opts.unpadded ? 1 : 3;
387 int before_blocks = w->stats.idx_stats.blocks;
387 - int err = writer_flush_block(w);
388 - int i = 0;
389 - struct reftable_block_stats *bstats = NULL;
388 + int err;
389 +
390 + err = writer_flush_block(w);
391 if (err < 0)
392 return err;
393
394 while (w->index_len > threshold) {
395 struct reftable_index_record *idx = NULL;
395 - int idx_len = 0;
396 + size_t i, idx_len;
397
398 max_level++;
399 index_start = w->next;
@@ -630,11 +631,8 @@ done:
631
632 static void writer_clear_index(struct reftable_writer *w)
633 {
633 - int i = 0;
634 - for (i = 0; i < w->index_len; i++) {
634 + for (size_t i = 0; i < w->index_len; i++)
635 strbuf_release(&w->index[i].last_key);
636 - }
637 -
636 FREE_AND_NULL(w->index);
637 w->index_len = 0;
638 w->index_cap = 0;