From 82c5f80fbd163317d823f4d700befc971562a1ea Mon Sep 17 00:00:00 2001 From: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> Date: Tue, 3 Aug 2021 18:56:46 -0700 Subject: [PATCH] More windows/linux fixes Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> --- Code/Framework/AzCore/AzCore/base.h | 20 +++++++++---------- Code/Framework/AzCore/Tests/Debug.cpp | 4 ++-- Code/Legacy/CryCommon/platform_impl.cpp | 2 +- Code/Legacy/CrySystem/DebugCallStack.cpp | 16 +++++++-------- .../Code/Editor/Animation/UiAnimViewNodes.cpp | 2 +- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Code/Framework/AzCore/AzCore/base.h b/Code/Framework/AzCore/AzCore/base.h index 00fdbf515e..20f5c17b27 100644 --- a/Code/Framework/AzCore/AzCore/base.h +++ b/Code/Framework/AzCore/AzCore/base.h @@ -71,7 +71,7 @@ // note: for cross-platform compatibility, do not use the return value of azfopen. On Windows, it's an errno_t and 0 indicates success. On other platforms, the return value is a FILE*, and a 0 value indicates failure. # define azfopen(_fp, _filename, _attrib) fopen_s(_fp, _filename, _attrib) -# define azfscanf fscanf_s +# define azfscanf fscanf_s # define azsprintf(_buffer, ...) sprintf_s(_buffer, AZ_ARRAY_SIZE(_buffer), __VA_ARGS__) # define azstrlwr _strlwr_s @@ -118,19 +118,19 @@ # define azfopen(_fp, _filename, _attrib) *(_fp) = fopen(_filename, _attrib) # define azfscanf fscanf -# define azsprintf sprintf -# define azstrlwr(_buffer, _size) strlwr(_buffer) -# define azvsprintf vsprintf -# define azwcscpy(_dest, _size, _buffer) wcscpy(_dest, _buffer) -# define azstrtime _strtime -# define azstrdate _strdate -# define azlocaltime localtime_r +# define azsprintf sprintf +# define azstrlwr(_buffer, _size) strlwr(_buffer) +# define azvsprintf vsprintf +# define azwcscpy(_dest, _size, _buffer) wcscpy(_dest, _buffer) +# define azstrtime _strtime +# define azstrdate _strdate +# define azlocaltime localtime_r #endif #if AZ_TRAIT_USE_POSIX_STRERROR_R -# define azstrerror_s(_dst, _num, _err) strerror_r(_err, _dst, _num) +# define azstrerror_s(_dst, _num, _err) strerror_r(_err, _dst, _num) #else -# define azstrerror_s strerror_s +# define azstrerror_s strerror_s #endif #define AZ_INVALID_POINTER reinterpret_cast(0x0badf00dul) diff --git a/Code/Framework/AzCore/Tests/Debug.cpp b/Code/Framework/AzCore/Tests/Debug.cpp index 3d214ffc68..6181823737 100644 --- a/Code/Framework/AzCore/Tests/Debug.cpp +++ b/Code/Framework/AzCore/Tests/Debug.cpp @@ -56,7 +56,7 @@ namespace UnitTest int isFoundModule = 0; char expectedNameBuffer[AZ_ARRAY_SIZE(SymbolStorage::ModuleInfo::m_modName)]; #if defined(AZCORETEST_DLL_NAME) - azstrncpy(expectedNameBuffer, AZCORETEST_DLL_NAME, AZ_ARRAY_SIZE(expectedNameBuffer)); + azstrncpy(expectedNameBuffer, AZ_ARRAY_SIZE(expectedNameBuffer), AZCORETEST_DLL_NAME, AZ_ARRAY_SIZE(expectedNameBuffer)); #else azstrncpy(expectedNameBuffer, "azcoretests.dll", AZ_ARRAY_SIZE(expectedNameBuffer)); #endif @@ -65,7 +65,7 @@ namespace UnitTest for (u32 i = 0; i < SymbolStorage::GetNumLoadedModules(); ++i) { char nameBuffer[AZ_ARRAY_SIZE(SymbolStorage::ModuleInfo::m_modName)]; - azstrncpy(nameBuffer, SymbolStorage::GetModuleInfo(i)->m_fileName, AZ_ARRAY_SIZE(nameBuffer)); + azstrncpy(nameBuffer, AZ_ARRAY_SIZE(nameBuffer), SymbolStorage::GetModuleInfo(i)->m_fileName, AZ_ARRAY_SIZE(nameBuffer)); AZStd::to_lower(nameBuffer, nameBuffer + AZ_ARRAY_SIZE(nameBuffer)); if (strstr(nameBuffer, expectedNameBuffer)) diff --git a/Code/Legacy/CryCommon/platform_impl.cpp b/Code/Legacy/CryCommon/platform_impl.cpp index 1523622538..3d7b2180fc 100644 --- a/Code/Legacy/CryCommon/platform_impl.cpp +++ b/Code/Legacy/CryCommon/platform_impl.cpp @@ -288,7 +288,7 @@ void InitRootDir(char szExeFileName[], uint nExeSize, char szExeRootName[], uint firstIteration = false; } // Check if the engineroot exists - azstrcat(szPath, "\\engine.json"); + azstrcat(szPath, AZ_ARRAY_SIZE(szPath), "\\engine.json"); WIN32_FILE_ATTRIBUTE_DATA data; AZStd::wstring szPathW; AZStd::to_wstring(szPathW, szPath); diff --git a/Code/Legacy/CrySystem/DebugCallStack.cpp b/Code/Legacy/CrySystem/DebugCallStack.cpp index c0923341ad..ef27ef2c59 100644 --- a/Code/Legacy/CrySystem/DebugCallStack.cpp +++ b/Code/Legacy/CrySystem/DebugCallStack.cpp @@ -419,8 +419,8 @@ void DebugCallStack::LogExceptionInfo(EXCEPTION_POINTERS* pex) char versionbuf[1024]; azstrcpy(versionbuf, AZ_ARRAY_SIZE(versionbuf), ""); PutVersion(versionbuf, AZ_ARRAY_SIZE(versionbuf)); - azstrcat(errorString, versionbuf); - azstrcat(errorString, "\n"); + azstrcat(errorString, AZ_ARRAY_SIZE(errorString), versionbuf); + azstrcat(errorString, AZ_ARRAY_SIZE(errorString), "\n"); char excCode[MAX_WARNING_LENGTH]; char excAddr[80]; @@ -486,7 +486,7 @@ void DebugCallStack::LogExceptionInfo(EXCEPTION_POINTERS* pex) excCode, excAddr, m_excModule, excName, desc); - azstrcat(errs, "\nCall Stack Trace:\n"); + azstrcat(errs, AZ_ARRAY_SIZE(errs), "\nCall Stack Trace:\n"); std::vector funcs; { @@ -509,15 +509,15 @@ void DebugCallStack::LogExceptionInfo(EXCEPTION_POINTERS* pex) { char temp[s_iCallStackSize]; sprintf_s(temp, "%2zd) %s", funcs.size() - i, (const char*)funcs[i].c_str()); - azstrcat(str, temp); - azstrcat(str, "\r\n"); - azstrcat(errs, temp); - azstrcat(errs, "\n"); + azstrcat(str, AZ_ARRAY_SIZE(str), temp); + azstrcat(str, AZ_ARRAY_SIZE(str), "\r\n"); + azstrcat(errs, AZ_ARRAY_SIZE(errs), temp); + azstrcat(errs, AZ_ARRAY_SIZE(errs), "\n"); } azstrcpy(m_excCallstack, AZ_ARRAY_SIZE(m_excCallstack), str); } - azstrcat(errorString, errs); + azstrcat(errorString, AZ_ARRAY_SIZE(errorString), errs); if (f) { diff --git a/Gems/LyShine/Code/Editor/Animation/UiAnimViewNodes.cpp b/Gems/LyShine/Code/Editor/Animation/UiAnimViewNodes.cpp index 67fd542c3f..679477e3d3 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAnimViewNodes.cpp +++ b/Gems/LyShine/Code/Editor/Animation/UiAnimViewNodes.cpp @@ -1512,7 +1512,7 @@ int CUiAnimViewNodesCtrl::GetMatNameAndSubMtlIndexFromName(QString& matName, con if (const char* pCh = strstr(nodeName, ".[")) { char matPath[MAX_PATH]; - azstrncpy(matPath, nodeName, (size_t)(pCh - nodeName)); + azstrncpy(matPath, AZ_ARRAY_SIZE(matPath), nodeName, (size_t)(pCh - nodeName)); matName = matPath; pCh += 2; if ((*pCh) != 0)