Skip to content

Commit eccce52

Browse files
peffgitster
authored andcommitted
oid_array: use size_t for iteration
The previous commit started using size_t for our allocations. There are some iterations that use int or unsigned, though. These aren't dangerous with respect to memory, but they could produce incorrect results. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 600bee4 commit eccce52

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sha1-array.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ int oid_array_for_each(struct oid_array *array,
4646
for_each_oid_fn fn,
4747
void *data)
4848
{
49-
int i;
49+
size_t i;
5050

5151
/* No oid_array_sort() here! See sha1-array.h */
5252

@@ -62,7 +62,7 @@ int oid_array_for_each_unique(struct oid_array *array,
6262
for_each_oid_fn fn,
6363
void *data)
6464
{
65-
int i;
65+
size_t i;
6666

6767
if (!array->sorted)
6868
oid_array_sort(array);
@@ -82,7 +82,7 @@ void oid_array_filter(struct oid_array *array,
8282
for_each_oid_fn want,
8383
void *cb_data)
8484
{
85-
unsigned nr = array->nr, src, dst;
85+
size_t nr = array->nr, src, dst;
8686
struct object_id *oids = array->oid;
8787

8888
for (src = dst = 0; src < nr; src++) {

0 commit comments

Comments
 (0)