Skip to content

Commit 33319b0

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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7c4c1cb commit 33319b0

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

reftable/record.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static int decode_string(struct reftable_buf *dest, struct string_view in)
126126
static int encode_string(const char *str, struct string_view s)
127127
{
128128
struct string_view start = s;
129-
int l = strlen(str);
129+
size_t l = strlen(str);
130130
int n = put_var_int(&s, l);
131131
if (n < 0)
132132
return -1;
@@ -565,7 +565,6 @@ static int reftable_obj_record_decode(void *rec, struct reftable_buf key,
565565
uint64_t count = val_type;
566566
int n = 0;
567567
uint64_t last;
568-
int j;
569568

570569
reftable_obj_record_release(r);
571570

@@ -600,8 +599,7 @@ static int reftable_obj_record_decode(void *rec, struct reftable_buf key,
600599
string_view_consume(&in, n);
601600

602601
last = r->offsets[0];
603-
j = 1;
604-
while (j < count) {
602+
for (uint64_t j = 1; j < count; j++) {
605603
uint64_t delta = 0;
606604
int n = get_var_int(&delta, &in);
607605
if (n < 0) {
@@ -610,7 +608,6 @@ static int reftable_obj_record_decode(void *rec, struct reftable_buf key,
610608
string_view_consume(&in, n);
611609

612610
last = r->offsets[j] = (delta + last);
613-
j++;
614611
}
615612
return start.len - in.len;
616613
}

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
/*

0 commit comments

Comments
 (0)