Skip to content

Commit 9ebb2d7

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d55fc51 commit 9ebb2d7

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

reftable/writer.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -379,20 +379,21 @@ int reftable_writer_add_logs(struct reftable_writer *w,
379379

380380
static int writer_finish_section(struct reftable_writer *w)
381381
{
382+
struct reftable_block_stats *bstats = NULL;
382383
uint8_t typ = block_writer_type(w->block_writer);
383384
uint64_t index_start = 0;
384385
int max_level = 0;
385-
int threshold = w->opts.unpadded ? 1 : 3;
386+
size_t threshold = w->opts.unpadded ? 1 : 3;
386387
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);
390391
if (err < 0)
391392
return err;
392393

393394
while (w->index_len > threshold) {
394395
struct reftable_index_record *idx = NULL;
395-
int idx_len = 0;
396+
size_t i, idx_len;
396397

397398
max_level++;
398399
index_start = w->next;
@@ -630,11 +631,8 @@ int reftable_writer_close(struct reftable_writer *w)
630631

631632
static void writer_clear_index(struct reftable_writer *w)
632633
{
633-
int i = 0;
634-
for (i = 0; i < w->index_len; i++) {
634+
for (size_t i = 0; i < w->index_len; i++)
635635
strbuf_release(&w->index[i].last_key);
636-
}
637-
638636
FREE_AND_NULL(w->index);
639637
w->index_len = 0;
640638
w->index_cap = 0;

0 commit comments

Comments
 (0)