]> git.ipfire.org Git - thirdparty/git.git/commitdiff
oid_array: use size_t for iteration
authorJeff King <peff@peff.net>
Mon, 30 Mar 2020 14:03:20 +0000 (10:03 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 30 Mar 2020 17:59:08 +0000 (10:59 -0700)
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>
sha1-array.c

index 3eeadfede94b94ed017b9196ebf42041d1e30c74..bada0c43537b47abc87b1e07f1044b5293eeac73 100644 (file)
@@ -46,7 +46,7 @@ int oid_array_for_each(struct oid_array *array,
                       for_each_oid_fn fn,
                       void *data)
 {
-       int i;
+       size_t i;
 
        /* No oid_array_sort() here! See sha1-array.h */
 
@@ -62,7 +62,7 @@ int oid_array_for_each_unique(struct oid_array *array,
                              for_each_oid_fn fn,
                              void *data)
 {
-       int i;
+       size_t i;
 
        if (!array->sorted)
                oid_array_sort(array);
@@ -82,7 +82,7 @@ void oid_array_filter(struct oid_array *array,
                      for_each_oid_fn want,
                      void *cb_data)
 {
-       unsigned nr = array->nr, src, dst;
+       size_t nr = array->nr, src, dst;
        struct object_id *oids = array->oid;
 
        for (src = dst = 0; src < nr; src++) {