From 22f2c3732221e68d0ef8b4e978f12eda2c4e3f87 Mon Sep 17 00:00:00 2001 From: Josiah VanderZee Date: Sat, 16 Dec 2023 11:55:42 -0600 Subject: [PATCH] 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. --- include/irrString.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/irrString.h b/include/irrString.h index 1e9a968..7c56f98 100644 --- a/include/irrString.h +++ b/include/irrString.h @@ -266,7 +266,7 @@ public: the trailing NUL. */ u32 size() const { - return str.size(); + return static_cast(str.size()); } //! Informs if the string is empty or not. @@ -834,7 +834,7 @@ public: if (!delimiter) return 0; - const u32 oldSize=ret.size(); + const u32 oldSize=static_cast(ret.size()); u32 tokenStartIdx = 0; for (u32 i=0; i()); - return ret.size()-oldSize; + return static_cast(ret.size()-oldSize); } // This function should not be used and is only kept for "CGUIFileOpenDialog::pathToStringW". @@ -888,10 +888,10 @@ private: return len; } static inline u32 calclen(const char* p) { - return strlen(p); + return static_cast(strlen(p)); } static inline u32 calclen(const wchar_t* p) { - return wcslen(p); + return static_cast(wcslen(p)); } //! strcmp wrapper