commit-reach: use size_t to track indices in get_reachable_subset()

Similar as with the preceding commit, adapt `get_reachable_subset()` so
that it tracks array indices via `size_t` instead of using signed
integers to fix a couple of -Wsign-compare warnings. Adapt callers
accordingly.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2024-12-27 11:46:25 +01:00
committed by Junio C Hamano
parent 45843d8f4e
commit 85ee0680e2
7 changed files with 17 additions and 16 deletions

View File

@ -780,10 +780,10 @@ static struct commit *get_commit_reference(struct repository *r,
} }
static struct commit **get_bad_and_good_commits(struct repository *r, static struct commit **get_bad_and_good_commits(struct repository *r,
int *rev_nr) size_t *rev_nr)
{ {
struct commit **rev; struct commit **rev;
int i, n = 0; size_t i, n = 0;
ALLOC_ARRAY(rev, 1 + good_revs.nr); ALLOC_ARRAY(rev, 1 + good_revs.nr);
rev[n++] = get_commit_reference(r, current_bad_oid); rev[n++] = get_commit_reference(r, current_bad_oid);
@ -887,7 +887,7 @@ static enum bisect_error check_merge_bases(int rev_nr, struct commit **rev, int
return res; return res;
} }
static int check_ancestors(struct repository *r, int rev_nr, static int check_ancestors(struct repository *r, size_t rev_nr,
struct commit **rev, const char *prefix) struct commit **rev, const char *prefix)
{ {
struct strvec rev_argv = STRVEC_INIT; struct strvec rev_argv = STRVEC_INIT;
@ -922,7 +922,8 @@ static enum bisect_error check_good_are_ancestors_of_bad(struct repository *r,
{ {
char *filename; char *filename;
struct stat st; struct stat st;
int fd, rev_nr; int fd;
size_t rev_nr;
enum bisect_error res = BISECT_OK; enum bisect_error res = BISECT_OK;
struct commit **rev; struct commit **rev;

View File

@ -791,8 +791,8 @@ int can_all_from_reach_with_flag(struct object_array *from,
timestamp_t min_generation) timestamp_t min_generation)
{ {
struct commit **list = NULL; struct commit **list = NULL;
int i; size_t i;
int nr_commits; size_t nr_commits;
int result = 1; int result = 1;
ALLOC_ARRAY(list, from->nr); ALLOC_ARRAY(list, from->nr);
@ -944,8 +944,8 @@ int can_all_from_reach(struct commit_list *from, struct commit_list *to,
return result; return result;
} }
struct commit_list *get_reachable_subset(struct commit **from, int nr_from, struct commit_list *get_reachable_subset(struct commit **from, size_t nr_from,
struct commit **to, int nr_to, struct commit **to, size_t nr_to,
unsigned int reachable_flag) unsigned int reachable_flag)
{ {
struct commit **item; struct commit **item;

View File

@ -95,8 +95,8 @@ int can_all_from_reach(struct commit_list *from, struct commit_list *to,
* This method uses the PARENT1 and PARENT2 flags during its operation, * This method uses the PARENT1 and PARENT2 flags during its operation,
* so be sure these flags are not set before calling the method. * so be sure these flags are not set before calling the method.
*/ */
struct commit_list *get_reachable_subset(struct commit **from, int nr_from, struct commit_list *get_reachable_subset(struct commit **from, size_t nr_from,
struct commit **to, int nr_to, struct commit **to, size_t nr_to,
unsigned int reachable_flag); unsigned int reachable_flag);
struct ahead_behind_count { struct ahead_behind_count {

View File

@ -778,11 +778,11 @@ static void clear_commit_marks_1(struct commit_list **plist,
} }
} }
void clear_commit_marks_many(int nr, struct commit **commit, unsigned int mark) void clear_commit_marks_many(size_t nr, struct commit **commit, unsigned int mark)
{ {
struct commit_list *list = NULL; struct commit_list *list = NULL;
while (nr--) { for (size_t i = 0; i < nr; i++) {
clear_commit_marks_1(&list, *commit, mark); clear_commit_marks_1(&list, *commit, mark);
commit++; commit++;
} }

View File

@ -210,7 +210,7 @@ struct commit *pop_most_recent_commit(struct commit_list **list,
struct commit *pop_commit(struct commit_list **stack); struct commit *pop_commit(struct commit_list **stack);
void clear_commit_marks(struct commit *commit, unsigned int mark); void clear_commit_marks(struct commit *commit, unsigned int mark);
void clear_commit_marks_many(int nr, struct commit **commit, unsigned int mark); void clear_commit_marks_many(size_t nr, struct commit **commit, unsigned int mark);
enum rev_sort_order { enum rev_sort_order {

View File

@ -3041,7 +3041,7 @@ static void reach_filter(struct ref_array *array,
struct commit_list **check_reachable, struct commit_list **check_reachable,
int include_reached) int include_reached)
{ {
int i, old_nr; size_t i, old_nr;
struct commit **to_clear; struct commit **to_clear;
if (!*check_reachable) if (!*check_reachable)

View File

@ -1535,7 +1535,7 @@ static struct ref **tail_ref(struct ref **head)
struct tips { struct tips {
struct commit **tip; struct commit **tip;
int nr, alloc; size_t nr, alloc;
}; };
static void add_to_tips(struct tips *tips, const struct object_id *oid) static void add_to_tips(struct tips *tips, const struct object_id *oid)
@ -1602,7 +1602,7 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds
const int reachable_flag = 1; const int reachable_flag = 1;
struct commit_list *found_commits; struct commit_list *found_commits;
struct commit **src_commits; struct commit **src_commits;
int nr_src_commits = 0, alloc_src_commits = 16; size_t nr_src_commits = 0, alloc_src_commits = 16;
ALLOC_ARRAY(src_commits, alloc_src_commits); ALLOC_ARRAY(src_commits, alloc_src_commits);
for_each_string_list_item(item, &src_tag) { for_each_string_list_item(item, &src_tag) {