Skip to content

Commit 071bcaa

Browse files
ramsay-jonesgitster
authored andcommitted
ALLOC_GROW: avoid -Wsign-compare warnings
Signed-off-by: Ramsay Jones <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 356a293 commit 071bcaa

File tree

7 files changed

+16
-17
lines changed

7 files changed

+16
-17
lines changed

builtin/pack-objects.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2556,8 +2556,8 @@ struct in_pack_object {
25562556
};
25572557

25582558
struct in_pack {
2559-
int alloc;
2560-
int nr;
2559+
unsigned int alloc;
2560+
unsigned int nr;
25612561
struct in_pack_object *array;
25622562
};
25632563

config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2159,7 +2159,7 @@ static struct {
21592159
size_t *offset;
21602160
unsigned int offset_alloc;
21612161
enum { START, SECTION_SEEN, SECTION_END_SEEN, KEY_SEEN } state;
2162-
int seen;
2162+
unsigned int seen;
21632163
} store;
21642164

21652165
static int matches(const char *key, const char *value)

diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ static void emit_rewrite_diff(const char *name_a,
825825

826826
struct diff_words_buffer {
827827
mmfile_t text;
828-
long alloc;
828+
unsigned long alloc;
829829
struct diff_words_orig {
830830
const char *begin, *end;
831831
} *orig;

line-log.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static int range_cmp(const void *_r, const void *_s)
9090
*/
9191
static void range_set_check_invariants(struct range_set *rs)
9292
{
93-
int i;
93+
unsigned int i;
9494

9595
if (!rs)
9696
return;
@@ -110,8 +110,8 @@ static void range_set_check_invariants(struct range_set *rs)
110110
*/
111111
void sort_and_merge_range_set(struct range_set *rs)
112112
{
113-
int i;
114-
int o = 0; /* output cursor */
113+
unsigned int i;
114+
unsigned int o = 0; /* output cursor */
115115

116116
QSORT(rs->ranges, rs->nr, range_cmp);
117117

@@ -144,7 +144,7 @@ void sort_and_merge_range_set(struct range_set *rs)
144144
static void range_set_union(struct range_set *out,
145145
struct range_set *a, struct range_set *b)
146146
{
147-
int i = 0, j = 0;
147+
unsigned int i = 0, j = 0;
148148
struct range *ra = a->ranges;
149149
struct range *rb = b->ranges;
150150
/* cannot make an alias of out->ranges: it may change during grow */
@@ -186,7 +186,7 @@ static void range_set_union(struct range_set *out,
186186
static void range_set_difference(struct range_set *out,
187187
struct range_set *a, struct range_set *b)
188188
{
189-
int i, j = 0;
189+
unsigned int i, j = 0;
190190
for (i = 0; i < a->nr; i++) {
191191
long start = a->ranges[i].start;
192192
long end = a->ranges[i].end;
@@ -397,7 +397,7 @@ static void diff_ranges_filter_touched(struct diff_ranges *out,
397397
struct diff_ranges *diff,
398398
struct range_set *rs)
399399
{
400-
int i, j = 0;
400+
unsigned int i, j = 0;
401401

402402
assert(out->target.nr == 0);
403403

@@ -426,7 +426,7 @@ static void range_set_shift_diff(struct range_set *out,
426426
struct range_set *rs,
427427
struct diff_ranges *diff)
428428
{
429-
int i, j = 0;
429+
unsigned int i, j = 0;
430430
long offset = 0;
431431
struct range *src = rs->ranges;
432432
struct range *target = diff->target.ranges;
@@ -873,7 +873,7 @@ static char *output_prefix(struct diff_options *opt)
873873

874874
static void dump_diff_hacky_one(struct rev_info *rev, struct line_log_data *range)
875875
{
876-
int i, j = 0;
876+
unsigned int i, j = 0;
877877
long p_lines, t_lines;
878878
unsigned long *p_ends = NULL, *t_ends = NULL;
879879
struct diff_filepair *pair = range->pair;
@@ -906,7 +906,7 @@ static void dump_diff_hacky_one(struct rev_info *rev, struct line_log_data *rang
906906
long t_start = range->ranges.ranges[i].start;
907907
long t_end = range->ranges.ranges[i].end;
908908
long t_cur = t_start;
909-
int j_last;
909+
unsigned int j_last;
910910

911911
while (j < diff->target.nr && diff->target.ranges[j].end < t_start)
912912
j++;

line-log.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct range {
1414

1515
/* A set of ranges. The ranges must always be disjoint and sorted. */
1616
struct range_set {
17-
int alloc, nr;
17+
unsigned int alloc, nr;
1818
struct range *ranges;
1919
};
2020

revision.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ static void add_rev_cmdline(struct rev_info *revs,
11031103
unsigned flags)
11041104
{
11051105
struct rev_cmdline_info *info = &revs->cmdline;
1106-
int nr = info->nr;
1106+
unsigned int nr = info->nr;
11071107

11081108
ALLOC_GROW(info->rev, nr + 1, info->alloc);
11091109
info->rev[nr].item = item;

tree-walk.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,12 +581,11 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s
581581
int retval = MISSING_OBJECT;
582582
struct dir_state *parents = NULL;
583583
size_t parents_alloc = 0;
584-
ssize_t parents_nr = 0;
584+
size_t i, parents_nr = 0;
585585
unsigned char current_tree_sha1[20];
586586
struct strbuf namebuf = STRBUF_INIT;
587587
struct tree_desc t;
588588
int follows_remaining = GET_TREE_ENTRY_FOLLOW_SYMLINKS_MAX_LINKS;
589-
int i;
590589

591590
init_tree_desc(&t, NULL, 0UL);
592591
strbuf_addstr(&namebuf, name);

0 commit comments

Comments
 (0)