Skip to content

Commit 3f287e0

Browse files
pks-tgitster
authored andcommitted
reftable: address trivial -Wsign-compare warnings
Address the last couple of trivial -Wsign-compare warnings in the reftable library and remove the DISABLE_SIGN_COMPARE_WARNINGS macro that we have in "reftable/system.h". Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent de4974b commit 3f287e0

File tree

4 files changed

+8
-15
lines changed

4 files changed

+8
-15
lines changed

reftable/record.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static int decode_string(struct reftable_buf *dest, struct string_view in)
117117
static int encode_string(const char *str, struct string_view s)
118118
{
119119
struct string_view start = s;
120-
int l = strlen(str);
120+
size_t l = strlen(str);
121121
int n = put_var_int(&s, l);
122122
if (n < 0)
123123
return -1;
@@ -556,7 +556,6 @@ static int reftable_obj_record_decode(void *rec, struct reftable_buf key,
556556
uint64_t count = val_type;
557557
int n = 0;
558558
uint64_t last;
559-
int j;
560559

561560
reftable_obj_record_release(r);
562561

@@ -591,8 +590,7 @@ static int reftable_obj_record_decode(void *rec, struct reftable_buf key,
591590
string_view_consume(&in, n);
592591

593592
last = r->offsets[0];
594-
j = 1;
595-
while (j < count) {
593+
for (uint64_t j = 1; j < count; j++) {
596594
uint64_t delta = 0;
597595
int n = get_var_int(&delta, &in);
598596
if (n < 0) {
@@ -601,7 +599,6 @@ static int reftable_obj_record_decode(void *rec, struct reftable_buf key,
601599
string_view_consume(&in, n);
602600

603601
last = r->offsets[j] = (delta + last);
604-
j++;
605602
}
606603
return start.len - in.len;
607604
}

reftable/stack.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,9 @@ void reftable_stack_destroy(struct reftable_stack *st)
220220
}
221221

222222
if (st->readers) {
223-
int i = 0;
224223
struct reftable_buf filename = REFTABLE_BUF_INIT;
225-
for (i = 0; i < st->readers_len; i++) {
224+
225+
for (size_t i = 0; i < st->readers_len; i++) {
226226
const char *name = reader_name(st->readers[i]);
227227
int try_unlinking = 1;
228228

@@ -238,6 +238,7 @@ void reftable_stack_destroy(struct reftable_stack *st)
238238
unlink(filename.buf);
239239
}
240240
}
241+
241242
reftable_buf_release(&filename);
242243
st->readers_len = 0;
243244
REFTABLE_FREE_AND_NULL(st->readers);
@@ -568,7 +569,6 @@ static int stack_uptodate(struct reftable_stack *st)
568569
{
569570
char **names = NULL;
570571
int err;
571-
int i = 0;
572572

573573
/*
574574
* When we have cached stat information available then we use it to
@@ -608,7 +608,7 @@ static int stack_uptodate(struct reftable_stack *st)
608608
if (err < 0)
609609
return err;
610610

611-
for (i = 0; i < st->readers_len; i++) {
611+
for (size_t i = 0; i < st->readers_len; i++) {
612612
if (!names[i]) {
613613
err = 1;
614614
goto done;
@@ -1767,14 +1767,12 @@ static int reftable_stack_clean_locked(struct reftable_stack *st)
17671767
}
17681768

17691769
while ((d = readdir(dir))) {
1770-
int i = 0;
17711770
int found = 0;
17721771
if (!is_table_name(d->d_name))
17731772
continue;
17741773

1775-
for (i = 0; !found && i < st->readers_len; i++) {
1774+
for (size_t i = 0; !found && i < st->readers_len; i++)
17761775
found = !strcmp(reader_name(st->readers[i]), d->d_name);
1777-
}
17781776
if (found)
17791777
continue;
17801778

reftable/system.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ license that can be found in the LICENSE file or at
1111

1212
/* This header glues the reftable library to the rest of Git */
1313

14-
#define DISABLE_SIGN_COMPARE_WARNINGS
15-
1614
#include "git-compat-util.h"
1715

1816
/*

reftable/writer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ static int writer_finish_section(struct reftable_writer *w)
577577

578578
struct common_prefix_arg {
579579
struct reftable_buf *last;
580-
int max;
580+
size_t max;
581581
};
582582

583583
static void update_common(void *void_arg, void *key)

0 commit comments

Comments
 (0)