Skip to content

Commit 85ee068

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 45843d8 commit 85ee068

File tree

7 files changed

+17
-16
lines changed

7 files changed

+17
-16
lines changed

bisect.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -780,10 +780,10 @@ static struct commit *get_commit_reference(struct repository *r,
780780
}
781781

782782
static struct commit **get_bad_and_good_commits(struct repository *r,
783-
int *rev_nr)
783+
size_t *rev_nr)
784784
{
785785
struct commit **rev;
786-
int i, n = 0;
786+
size_t i, n = 0;
787787

788788
ALLOC_ARRAY(rev, 1 + good_revs.nr);
789789
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
887887
return res;
888888
}
889889

890-
static int check_ancestors(struct repository *r, int rev_nr,
890+
static int check_ancestors(struct repository *r, size_t rev_nr,
891891
struct commit **rev, const char *prefix)
892892
{
893893
struct strvec rev_argv = STRVEC_INIT;
@@ -922,7 +922,8 @@ static enum bisect_error check_good_are_ancestors_of_bad(struct repository *r,
922922
{
923923
char *filename;
924924
struct stat st;
925-
int fd, rev_nr;
925+
int fd;
926+
size_t rev_nr;
926927
enum bisect_error res = BISECT_OK;
927928
struct commit **rev;
928929

commit-reach.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -791,8 +791,8 @@ int can_all_from_reach_with_flag(struct object_array *from,
791791
timestamp_t min_generation)
792792
{
793793
struct commit **list = NULL;
794-
int i;
795-
int nr_commits;
794+
size_t i;
795+
size_t nr_commits;
796796
int result = 1;
797797

798798
ALLOC_ARRAY(list, from->nr);
@@ -944,8 +944,8 @@ int can_all_from_reach(struct commit_list *from, struct commit_list *to,
944944
return result;
945945
}
946946

947-
struct commit_list *get_reachable_subset(struct commit **from, int nr_from,
948-
struct commit **to, int nr_to,
947+
struct commit_list *get_reachable_subset(struct commit **from, size_t nr_from,
948+
struct commit **to, size_t nr_to,
949949
unsigned int reachable_flag)
950950
{
951951
struct commit **item;

commit-reach.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ int can_all_from_reach(struct commit_list *from, struct commit_list *to,
9595
* This method uses the PARENT1 and PARENT2 flags during its operation,
9696
* so be sure these flags are not set before calling the method.
9797
*/
98-
struct commit_list *get_reachable_subset(struct commit **from, int nr_from,
99-
struct commit **to, int nr_to,
98+
struct commit_list *get_reachable_subset(struct commit **from, size_t nr_from,
99+
struct commit **to, size_t nr_to,
100100
unsigned int reachable_flag);
101101

102102
struct ahead_behind_count {

commit.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,11 +778,11 @@ static void clear_commit_marks_1(struct commit_list **plist,
778778
}
779779
}
780780

781-
void clear_commit_marks_many(int nr, struct commit **commit, unsigned int mark)
781+
void clear_commit_marks_many(size_t nr, struct commit **commit, unsigned int mark)
782782
{
783783
struct commit_list *list = NULL;
784784

785-
while (nr--) {
785+
for (size_t i = 0; i < nr; i++) {
786786
clear_commit_marks_1(&list, *commit, mark);
787787
commit++;
788788
}

commit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ struct commit *pop_most_recent_commit(struct commit_list **list,
210210
struct commit *pop_commit(struct commit_list **stack);
211211

212212
void clear_commit_marks(struct commit *commit, unsigned int mark);
213-
void clear_commit_marks_many(int nr, struct commit **commit, unsigned int mark);
213+
void clear_commit_marks_many(size_t nr, struct commit **commit, unsigned int mark);
214214

215215

216216
enum rev_sort_order {

ref-filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3041,7 +3041,7 @@ static void reach_filter(struct ref_array *array,
30413041
struct commit_list **check_reachable,
30423042
int include_reached)
30433043
{
3044-
int i, old_nr;
3044+
size_t i, old_nr;
30453045
struct commit **to_clear;
30463046

30473047
if (!*check_reachable)

remote.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,7 +1535,7 @@ static struct ref **tail_ref(struct ref **head)
15351535

15361536
struct tips {
15371537
struct commit **tip;
1538-
int nr, alloc;
1538+
size_t nr, alloc;
15391539
};
15401540

15411541
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
16021602
const int reachable_flag = 1;
16031603
struct commit_list *found_commits;
16041604
struct commit **src_commits;
1605-
int nr_src_commits = 0, alloc_src_commits = 16;
1605+
size_t nr_src_commits = 0, alloc_src_commits = 16;
16061606
ALLOC_ARRAY(src_commits, alloc_src_commits);
16071607

16081608
for_each_string_list_item(item, &src_tag) {

0 commit comments

Comments
 (0)