refs: use `size_t` indexes when iterating over ref transaction updates

Eliminate any chance of integer overflow on platforms where the two types have different sizes. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed May 22, 2017 at 16:17 UTC 43a2dfde76a4a47ffa31be11fd5cd7fe0b57bb84
2 files changed +5 -3
refs.c
+1 -1
@@ -848,7 +848,7 @@ struct ref_transaction *ref_transaction_begin(struct strbuf *err)
848
849 void ref_transaction_free(struct ref_transaction *transaction)
850 {
851 - int i;
851 + size_t i;
852
853 if (!transaction)
854 return;
refs/files-backend.c
+4 -2
@@ -2850,7 +2850,8 @@ static int files_transaction_commit(struct ref_store *ref_store,
2850 struct files_ref_store *refs =
2851 files_downcast(ref_store, REF_STORE_WRITE,
2852 "ref_transaction_commit");
2853 - int ret = 0, i;
2853 + size_t i;
2854 + int ret = 0;
2855 struct string_list refs_to_delete = STRING_LIST_INIT_NODUP;
2856 struct string_list_item *ref_to_delete;
2857 struct string_list affected_refnames = STRING_LIST_INIT_NODUP;
@@ -3057,7 +3058,8 @@ static int files_initial_transaction_commit(struct ref_store *ref_store,
3058 struct files_ref_store *refs =
3059 files_downcast(ref_store, REF_STORE_WRITE,
3060 "initial_ref_transaction_commit");
3060 - int ret = 0, i;
3061 + size_t i;
3062 + int ret = 0;
3063 struct string_list affected_refnames = STRING_LIST_INIT_NODUP;
3064
3065 assert(err);