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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Mar 30, 2020 at 10:03 UTC
eccce5253b9bfb17238f7d94c9ccf1cfd935eeb2
1 file changed
+3
-3
sha1-array.c
+3
-3
@@ -46,7 +46,7 @@ int oid_array_for_each(struct oid_array *array,
46
for_each_oid_fn fn,
47
void *data)
48
{
49
- int i;
49
+ size_t i;
50
51
/* No oid_array_sort() here! See sha1-array.h */
52
@@ -62,7 +62,7 @@ int oid_array_for_each_unique(struct oid_array *array,
62
for_each_oid_fn fn,
63
void *data)
64
{
65
- int i;
65
+ size_t i;
66
67
if (!array->sorted)
68
oid_array_sort(array);
@@ -82,7 +82,7 @@ void oid_array_filter(struct oid_array *array,
82
for_each_oid_fn want,
83
void *cb_data)
84
{
85
- unsigned nr = array->nr, src, dst;
85
+ size_t nr = array->nr, src, dst;
86
struct object_id *oids = array->oid;
87
88
for (src = dst = 0; src < nr; src++) {