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>

Patrick Steinhardt committed Jan 20, 2025 at 17:17 UTC 33319b0976ff9975e7509b6096887370146893f4
3 files changed +7 -14
reftable/record.c
+2 -5
@@ -126,7 +126,7 @@ static int decode_string(struct reftable_buf *dest, struct string_view in)
126 static int encode_string(const char *str, struct string_view s)
127 {
128 struct string_view start = s;
129 - int l = strlen(str);
129 + size_t l = strlen(str);
130 int n = put_var_int(&s, l);
131 if (n < 0)
132 return -1;
@@ -565,7 +565,6 @@ static int reftable_obj_record_decode(void *rec, struct reftable_buf key,
565 uint64_t count = val_type;
566 int n = 0;
567 uint64_t last;
568 - int j;
568
569 reftable_obj_record_release(r);
570
@@ -600,8 +599,7 @@ static int reftable_obj_record_decode(void *rec, struct reftable_buf key,
599 string_view_consume(&in, n);
600
601 last = r->offsets[0];
603 - j = 1;
604 - while (j < count) {
602 + for (uint64_t j = 1; j < count; j++) {
603 uint64_t delta = 0;
604 int n = get_var_int(&delta, &in);
605 if (n < 0) {
@@ -610,7 +608,6 @@ static int reftable_obj_record_decode(void *rec, struct reftable_buf key,
608 string_view_consume(&in, n);
609
610 last = r->offsets[j] = (delta + last);
613 - j++;
611 }
612 return start.len - in.len;
613 }
reftable/stack.c
+5 -7
@@ -220,9 +220,9 @@ void reftable_stack_destroy(struct reftable_stack *st)
220 }
221
222 if (st->readers) {
223 - int i = 0;
223 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++) {
226 const char *name = reader_name(st->readers[i]);
227 int try_unlinking = 1;
228
@@ -238,6 +238,7 @@ void reftable_stack_destroy(struct reftable_stack *st)
238 unlink(filename.buf);
239 }
240 }
241 +
242 reftable_buf_release(&filename);
243 st->readers_len = 0;
244 REFTABLE_FREE_AND_NULL(st->readers);
@@ -568,7 +569,6 @@ static int stack_uptodate(struct reftable_stack *st)
569 {
570 char **names = NULL;
571 int err;
571 - int i = 0;
572
573 /*
574 * When we have cached stat information available then we use it to
@@ -608,7 +608,7 @@ static int stack_uptodate(struct reftable_stack *st)
608 if (err < 0)
609 return err;
610
611 - for (i = 0; i < st->readers_len; i++) {
611 + for (size_t i = 0; i < st->readers_len; i++) {
612 if (!names[i]) {
613 err = 1;
614 goto done;
@@ -1767,14 +1767,12 @@ static int reftable_stack_clean_locked(struct reftable_stack *st)
1767 }
1768
1769 while ((d = readdir(dir))) {
1770 - int i = 0;
1770 int found = 0;
1771 if (!is_table_name(d->d_name))
1772 continue;
1773
1775 - for (i = 0; !found && i < st->readers_len; i++) {
1774 + for (size_t i = 0; !found && i < st->readers_len; i++)
1775 found = !strcmp(reader_name(st->readers[i]), d->d_name);
1777 - }
1776 if (found)
1777 continue;
1778
reftable/system.h
-2
@@ -11,8 +11,6 @@ https://developers.google.com/open-source/licenses/bsd
11
12 /* This header glues the reftable library to the rest of Git */
13
14 -#define DISABLE_SIGN_COMPARE_WARNINGS
15 -
14 #include "git-compat-util.h"
15
16 /*