Add size_t to u32 static_casts to irrString

The irrString implementation doesn't allow constructing a string with a
size that would exceed a u32, so it should be safe to narrow the size of
the underlying STL container back to a u32.

This fixes 5 narrowing cast warnings from Visual Studio 17 2022.
This commit is contained in:
Josiah VanderZee 2023-12-16 11:55:42 -06:00 committed by sfan5
parent 94cb0cc19d
commit 22f2c37322

View File

@ -266,7 +266,7 @@ public:
the trailing NUL. */ the trailing NUL. */
u32 size() const u32 size() const
{ {
return str.size(); return static_cast<u32>(str.size());
} }
//! Informs if the string is empty or not. //! Informs if the string is empty or not.
@ -834,7 +834,7 @@ public:
if (!delimiter) if (!delimiter)
return 0; return 0;
const u32 oldSize=ret.size(); const u32 oldSize=static_cast<u32>(ret.size());
u32 tokenStartIdx = 0; u32 tokenStartIdx = 0;
for (u32 i=0; i<size()+1; ++i) for (u32 i=0; i<size()+1; ++i)
@ -862,7 +862,7 @@ public:
else if (!ignoreEmptyTokens) else if (!ignoreEmptyTokens)
ret.push_back(string<T>()); ret.push_back(string<T>());
return ret.size()-oldSize; return static_cast<u32>(ret.size()-oldSize);
} }
// This function should not be used and is only kept for "CGUIFileOpenDialog::pathToStringW". // This function should not be used and is only kept for "CGUIFileOpenDialog::pathToStringW".
@ -888,10 +888,10 @@ private:
return len; return len;
} }
static inline u32 calclen(const char* p) { static inline u32 calclen(const char* p) {
return strlen(p); return static_cast<u32>(strlen(p));
} }
static inline u32 calclen(const wchar_t* p) { static inline u32 calclen(const wchar_t* p) {
return wcslen(p); return static_cast<u32>(wcslen(p));
} }
//! strcmp wrapper //! strcmp wrapper