From 651610cd2adaae00cf5ea48ffc662a04336ccf20 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Thu, 11 Jul 2024 01:43:18 +0100 Subject: [PATCH] Saveload: Fix sign and narrowing conversion warnings calculating list sizes --- src/sl/saveload.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sl/saveload.cpp b/src/sl/saveload.cpp index 5105013099..43a1fdc1cf 100644 --- a/src/sl/saveload.cpp +++ b/src/sl/saveload.cpp @@ -1578,8 +1578,8 @@ public: const SlStorageT *list = static_cast(storage); - int type_size = SlGetListTypeLengthSize(list->size()); // Size of the length of the list. - int item_size = SlCalcConvFileLen(cmd == SL_VAR ? conv : (VarType)SLE_FILE_U32); + uint type_size = SlGetListTypeLengthSize(list->size()); // Size of the length of the list. + uint item_size = SlCalcConvFileLen(cmd == SL_VAR ? conv : (VarType)SLE_FILE_U32); return list->size() * item_size + type_size; } @@ -1656,8 +1656,8 @@ static inline size_t SlCalcRefListLen(const void *list) { const PtrList *l = (const PtrList *) list; - int type_size = SlGetListTypeLengthSize(l->size()); - int item_size = SlCalcRefLen(); + uint type_size = SlGetListTypeLengthSize(l->size()); + size_t item_size = SlCalcRefLen(); /* Each entry is saved as item_size bytes, plus type_size bytes are used for the length * of the list */ return l->size() * item_size + type_size; @@ -1671,7 +1671,7 @@ static inline size_t SlCalcRefListLen(const void *list) static inline size_t SlCalcVarListLen(const void *list, size_t item_size) { const PtrList *l = (const PtrList *) list; - int type_size = SlGetListTypeLengthSize(l->size()); + uint type_size = SlGetListTypeLengthSize(l->size()); /* Each entry is saved as item_size bytes, plus type_size bytes are used for the length * of the list */ return l->size() * item_size + type_size;