diff --git a/Code/Editor/EditorViewportWidget.cpp b/Code/Editor/EditorViewportWidget.cpp index c305b1be6c..ec965cc51f 100644 --- a/Code/Editor/EditorViewportWidget.cpp +++ b/Code/Editor/EditorViewportWidget.cpp @@ -2634,7 +2634,6 @@ void EditorViewportWidget::ShowCursor() ////////////////////////////////////////////////////////////////////////// void EditorViewportWidget::PushDisableRendering() { - assert(m_disableRenderingCount >= 0); ++m_disableRenderingCount; } diff --git a/Code/Editor/Objects/BaseObject.cpp b/Code/Editor/Objects/BaseObject.cpp index 8eb3bb83c1..59a58e1ac1 100644 --- a/Code/Editor/Objects/BaseObject.cpp +++ b/Code/Editor/Objects/BaseObject.cpp @@ -2038,7 +2038,7 @@ bool CBaseObject::HitHelperAtTest(HitContext& hc, const Vec3& pos) ////////////////////////////////////////////////////////////////////////// CBaseObject* CBaseObject::GetChild(size_t const i) const { - assert(i >= 0 && i < m_childs.size()); + assert(i < m_childs.size()); return m_childs[i]; } @@ -2729,7 +2729,7 @@ void CBaseObject::SetMinSpec(uint32 nSpec, bool bSetChildren) // Set min spec for all childs. if (bSetChildren) { - for (size_t i = m_childs.size() - 1; i >= 0; --i) + for (int i = static_cast(m_childs.size()) - 1; i >= 0; --i) { m_childs[i]->SetMinSpec(nSpec, true); } diff --git a/Code/Editor/Objects/EntityObject.cpp b/Code/Editor/Objects/EntityObject.cpp index d2a2ae7d18..45aaa7919e 100644 --- a/Code/Editor/Objects/EntityObject.cpp +++ b/Code/Editor/Objects/EntityObject.cpp @@ -1413,7 +1413,7 @@ void CEntityObject::PostClone(CBaseObject* pFromObject, CObjectCloneContext& ctx void CEntityObject::ResolveEventTarget(CBaseObject* object, unsigned int index) { // Find target id. - assert(index >= 0 && index < m_eventTargets.size()); + assert(index < m_eventTargets.size()); if (object) { object->AddEventListener(this); diff --git a/Code/Editor/Undo/Undo.cpp b/Code/Editor/Undo/Undo.cpp index b49c6ea567..910a670bee 100644 --- a/Code/Editor/Undo/Undo.cpp +++ b/Code/Editor/Undo/Undo.cpp @@ -49,7 +49,7 @@ public: } void Undo(bool bUndo) override { - for (size_t i = m_undoSteps.size() - 1; i >= 0; i--) + for (int i = static_cast(m_undoSteps.size()) - 1; i >= 0; i--) { m_undoSteps[i]->Undo(bUndo); } diff --git a/Code/Editor/Util/3DConnexionDriver.cpp b/Code/Editor/Util/3DConnexionDriver.cpp index c1c3b47c4b..73e7954c88 100644 --- a/Code/Editor/Util/3DConnexionDriver.cpp +++ b/Code/Editor/Util/3DConnexionDriver.cpp @@ -60,34 +60,29 @@ bool C3DConnexionDriver::InitDevice() { UINT nchars = 300; TCHAR deviceName[300]; - if (GetRawInputDeviceInfo(m_pRawInputDeviceList[i].hDevice, - RIDI_DEVICENAME, deviceName, &nchars) >= 0) - { - //_RPT3(_CRT_WARN, "Device[%d]: handle=0x%x name = %S\n", i, g_pRawInputDeviceList[i].hDevice, deviceName); - } + GetRawInputDeviceInfo(m_pRawInputDeviceList[i].hDevice, + RIDI_DEVICENAME, deviceName, &nchars); RID_DEVICE_INFO dinfo; UINT sizeofdinfo = sizeof(dinfo); dinfo.cbSize = sizeofdinfo; - if (GetRawInputDeviceInfo(m_pRawInputDeviceList[i].hDevice, - RIDI_DEVICEINFO, &dinfo, &sizeofdinfo) >= 0) + GetRawInputDeviceInfo(m_pRawInputDeviceList[i].hDevice, + RIDI_DEVICEINFO, &dinfo, &sizeofdinfo); + if (dinfo.dwType == RIM_TYPEHID) { - if (dinfo.dwType == RIM_TYPEHID) + RID_DEVICE_INFO_HID* phidInfo = &dinfo.hid; + // Add this one to the list of interesting devices? + // Actually only have to do this once to get input from all usage 1, usagePage 8 devices + // This just keeps out the other usages. + // You might want to put up a list for users to select amongst the different devices. + // In particular, to assign separate functionality to the different devices. + if (phidInfo->usUsagePage == 1 && phidInfo->usUsage == 8) { - RID_DEVICE_INFO_HID* phidInfo = &dinfo.hid; - // Add this one to the list of interesting devices? - // Actually only have to do this once to get input from all usage 1, usagePage 8 devices - // This just keeps out the other usages. - // You might want to put up a list for users to select amongst the different devices. - // In particular, to assign separate functionality to the different devices. - if (phidInfo->usUsagePage == 1 && phidInfo->usUsage == 8) - { - m_pRawInputDevices[m_nUsagePage1Usage8Devices].usUsagePage = phidInfo->usUsagePage; - m_pRawInputDevices[m_nUsagePage1Usage8Devices].usUsage = phidInfo->usUsage; - m_pRawInputDevices[m_nUsagePage1Usage8Devices].dwFlags = 0; - m_pRawInputDevices[m_nUsagePage1Usage8Devices].hwndTarget = nullptr; - m_nUsagePage1Usage8Devices++; - } + m_pRawInputDevices[m_nUsagePage1Usage8Devices].usUsagePage = phidInfo->usUsagePage; + m_pRawInputDevices[m_nUsagePage1Usage8Devices].usUsage = phidInfo->usUsage; + m_pRawInputDevices[m_nUsagePage1Usage8Devices].dwFlags = 0; + m_pRawInputDevices[m_nUsagePage1Usage8Devices].hwndTarget = nullptr; + m_nUsagePage1Usage8Devices++; } } } diff --git a/Code/Editor/Util/KDTree.cpp b/Code/Editor/Util/KDTree.cpp index 182b9b8eb1..af06a58c9f 100644 --- a/Code/Editor/Util/KDTree.cpp +++ b/Code/Editor/Util/KDTree.cpp @@ -467,7 +467,7 @@ bool CKDTree::FindNearestVertexRecursively(KDTreeNode* pNode, const Vec3& raySrc uint32 nVertexIndex = pNode->GetVertexIndex(i); uint32 nObjIndex = pNode->GetObjIndex(i); - assert(nObjIndex < m_StatObjectList.size() && nObjIndex >= 0); + assert(nObjIndex < m_StatObjectList.size()); const SStatObj* pStatObjInfo = &(m_StatObjectList[nObjIndex]); diff --git a/Code/Editor/ViewPane.cpp b/Code/Editor/ViewPane.cpp index a932f05c79..421db8394e 100644 --- a/Code/Editor/ViewPane.cpp +++ b/Code/Editor/ViewPane.cpp @@ -769,7 +769,9 @@ namespace void PySetViewPaneLayout(unsigned int layoutId) { + AZ_PUSH_DISABLE_WARNING(4296, "-Wunknown-warning-option") if ((layoutId >= ET_Layout0) && (layoutId <= ET_Layout8)) + AZ_POP_DISABLE_WARNING { CLayoutWnd* layout = GetIEditor()->GetViewManager()->GetLayout(); if (layout) diff --git a/Code/Framework/AzCore/Platform/Common/WinAPI/AzCore/IO/Streamer/StreamerContext_WinAPI.cpp b/Code/Framework/AzCore/Platform/Common/WinAPI/AzCore/IO/Streamer/StreamerContext_WinAPI.cpp index cda0a3f056..8f46bc5eba 100644 --- a/Code/Framework/AzCore/Platform/Common/WinAPI/AzCore/IO/Streamer/StreamerContext_WinAPI.cpp +++ b/Code/Framework/AzCore/Platform/Common/WinAPI/AzCore/IO/Streamer/StreamerContext_WinAPI.cpp @@ -49,7 +49,7 @@ namespace AZ::Platform AZ_Assert(m_events[0], "There is no synchronization event created for the main streamer thread to use to suspend."); DWORD result = ::WaitForMultipleObjects(m_handleCount, m_events, false, INFINITE); - if (result >= WAIT_OBJECT_0 && result < WAIT_OBJECT_0 + m_handleCount) + if (result < WAIT_OBJECT_0 + m_handleCount) { DWORD index = result - WAIT_OBJECT_0; ::ResetEvent(m_events[index]); diff --git a/Code/Framework/AzCore/Tests/AZStd/VectorAndArray.cpp b/Code/Framework/AzCore/Tests/AZStd/VectorAndArray.cpp index dd10d20ef8..933db73c3f 100644 --- a/Code/Framework/AzCore/Tests/AZStd/VectorAndArray.cpp +++ b/Code/Framework/AzCore/Tests/AZStd/VectorAndArray.cpp @@ -36,12 +36,23 @@ using namespace UnitTestInternal; /** * Validate a vector for certain number of elements. */ -#define AZ_TEST_VALIDATE_VECTOR(_Vector, _NumElements) \ - EXPECT_TRUE(_Vector.validate()); \ - EXPECT_EQ(_NumElements, _Vector.size()); \ - EXPECT_TRUE((_NumElements > 0) ? !_Vector.empty() : _Vector.empty()); \ - EXPECT_TRUE((_NumElements > 0) ? _Vector.capacity() >= _NumElements : true); \ - EXPECT_TRUE((_NumElements > 0) ? _Vector.begin() != _Vector.end() : _Vector.begin() == _Vector.end()); \ +#define AZ_TEST_VALIDATE_VECTOR(_Vector, _NumElements) \ + EXPECT_NE(_NumElements, 0); \ + EXPECT_TRUE(_Vector.validate()); \ + EXPECT_EQ(_NumElements, _Vector.size()); \ + EXPECT_TRUE(!_Vector.empty()); \ + EXPECT_TRUE(_Vector.capacity() >= _NumElements); \ + EXPECT_TRUE(_Vector.begin() != _Vector.end()); \ + EXPECT_NE(nullptr, _Vector.data()) + + /** + * Validate a vector for 0 number of elements. The above macro creates expressions that are always true for size == 0 + */ +#define AZ_TEST_VALIDATE_VECTOR_0(_Vector) \ + EXPECT_TRUE(_Vector.validate()); \ + EXPECT_EQ(0, _Vector.size()); \ + EXPECT_TRUE(_Vector.empty()); \ + EXPECT_TRUE(_Vector.begin() == _Vector.end()); \ EXPECT_NE(nullptr, _Vector.data()) namespace UnitTest @@ -312,7 +323,7 @@ namespace UnitTest // erase int_vector1.erase(int_vector1.begin(), int_vector1.end()); - AZ_TEST_VALIDATE_VECTOR(int_vector1, 0); // Zero elements but valid capacity. + AZ_TEST_VALIDATE_VECTOR_0(int_vector1); // Zero elements but valid capacity. int_vector1.push_back(10); int_vector1.push_back(20); @@ -324,11 +335,11 @@ namespace UnitTest // clear int_vector1.clear(); - AZ_TEST_VALIDATE_VECTOR(int_vector1, 0); // Zero elements but valid capacity. + AZ_TEST_VALIDATE_VECTOR_0(int_vector1); // Zero elements but valid capacity. // swap int_vector1.swap(int_vector); - AZ_TEST_VALIDATE_VECTOR(int_vector, 0); + AZ_TEST_VALIDATE_VECTOR_0(int_vector); AZ_TEST_VALIDATE_VECTOR(int_vector1, 33); AZ_TEST_ASSERT(int_vector1.front() == 55); @@ -524,11 +535,11 @@ namespace UnitTest // Default vector (integral type). fixed_vector int_vector_default; - AZ_TEST_VALIDATE_VECTOR(int_vector_default, 0); + AZ_TEST_VALIDATE_VECTOR_0(int_vector_default); // Default vector (non-integral type). fixed_vector myclass_vector_default; - AZ_TEST_VALIDATE_VECTOR(myclass_vector_default, 0); + AZ_TEST_VALIDATE_VECTOR_0(myclass_vector_default); // Create a vector (using fill ctor, with memset optimization to set the values) typedef fixed_vector char_10_type; @@ -633,7 +644,7 @@ namespace UnitTest // erase int_vector1.erase(int_vector1.begin(), int_vector1.end()); - AZ_TEST_VALIDATE_VECTOR(int_vector1, 0); + AZ_TEST_VALIDATE_VECTOR_0(int_vector1); int_vector1.push_back(10); int_vector1.push_back(20); @@ -645,11 +656,11 @@ namespace UnitTest // clear int_vector1.clear(); - AZ_TEST_VALIDATE_VECTOR(int_vector1, 0); + AZ_TEST_VALIDATE_VECTOR_0(int_vector1); // swap int_vector1.swap(int_vector); - AZ_TEST_VALIDATE_VECTOR(int_vector, 0); + AZ_TEST_VALIDATE_VECTOR_0(int_vector); AZ_TEST_VALIDATE_VECTOR(int_vector1, 33); AZ_TEST_ASSERT(int_vector1.front() == 55); @@ -963,7 +974,7 @@ namespace UnitTest AZ_TEST_VALIDATE_VECTOR(deep_vec_2, 12); deep_vec_2.clear(); - AZ_TEST_VALIDATE_VECTOR(deep_vec_2, 0); + AZ_TEST_VALIDATE_VECTOR_0(deep_vec_2); } #endif // AZ_UNIT_TEST_SKIP_STD_VECTOR_AND_ARRAY_TESTS diff --git a/Code/Framework/AzFramework/AzFramework/IO/RemoteFileIO.cpp b/Code/Framework/AzFramework/AzFramework/IO/RemoteFileIO.cpp index 75b43100c5..25bc31b760 100644 --- a/Code/Framework/AzFramework/AzFramework/IO/RemoteFileIO.cpp +++ b/Code/Framework/AzFramework/AzFramework/IO/RemoteFileIO.cpp @@ -1081,16 +1081,6 @@ namespace AZ return ResultCode::Error; } - //bound check - //note that seeking beyond end or before beginning is system dependent - //therefore we will define that on all platforms it is not allowed - if (newFilePosition < 0) - { - AZ_TracePrintf(RemoteFileIOChannel, "RemoteFileIO::Seek(fileHandle=%u, offset=%i, type=%s) seek to a position before the begining of a file!", fileHandle, offset, type == SeekType::SeekFromCurrent ? "SeekFromCurrent" : type == SeekType::SeekFromEnd ? "SeekFromEnd" : type == SeekType::SeekFromStart ? "SeekFromStart" : "Unknown"); - REMOTEFILE_LOG_APPEND(AZStd::string::format("RemoteFileIO::Seek(fileHandle=%u, offset=%i, type=%s) seek to a position before the begining of a file!", fileHandle, offset, type == SeekType::SeekFromCurrent ? "SeekFromCurrent" : type == SeekType::SeekFromEnd ? "SeekFromEnd" : type == SeekType::SeekFromStart ? "SeekFromStart" : "Unknown").c_str()); - newFilePosition = 0; - } - else { AZ::u64 fileSize = 0; Size(fileHandle, fileSize); diff --git a/Code/Legacy/CryCommon/IXml.h b/Code/Legacy/CryCommon/IXml.h index 80c2415f9c..2434b44664 100644 --- a/Code/Legacy/CryCommon/IXml.h +++ b/Code/Legacy/CryCommon/IXml.h @@ -745,7 +745,7 @@ private: void Update() { - if (m_index >= 0 && m_index < m_parentNode->getChildCount()) + if (m_index < m_parentNode->getChildCount()) { m_currentChildNode = m_parentNode->getChild(static_cast(m_index)); } diff --git a/Code/Tools/AssetProcessor/native/resourcecompiler/rcjoblistmodel.cpp b/Code/Tools/AssetProcessor/native/resourcecompiler/rcjoblistmodel.cpp index d22823b496..a64e3bf5b9 100644 --- a/Code/Tools/AssetProcessor/native/resourcecompiler/rcjoblistmodel.cpp +++ b/Code/Tools/AssetProcessor/native/resourcecompiler/rcjoblistmodel.cpp @@ -197,11 +197,11 @@ namespace AssetProcessor m_jobsInFlight.insert(rcJob); - for(size_t jobIndex = m_jobs.size() - 1; jobIndex >= 0; --jobIndex) + for(int jobIndex = static_cast(m_jobs.size()) - 1; jobIndex >= 0; --jobIndex) { if(m_jobs[jobIndex] == rcJob) { - Q_EMIT dataChanged(index(aznumeric_caster(jobIndex), 0, QModelIndex()), index(aznumeric_caster(jobIndex), 0, QModelIndex())); + Q_EMIT dataChanged(index(jobIndex, 0, QModelIndex()), index(jobIndex, 0, QModelIndex())); return; } } @@ -240,7 +240,7 @@ namespace AssetProcessor foundInQueue = m_jobsInQueueLookup.erase(foundInQueue); } - for (size_t jobIndex = m_jobs.size() - 1; jobIndex >= 0; --jobIndex) + for (int jobIndex = static_cast(m_jobs.size()) - 1; jobIndex >= 0; --jobIndex) { if(m_jobs[jobIndex] == rcJob) { @@ -251,7 +251,7 @@ namespace AssetProcessor #if defined(DEBUG_RCJOB_MODEL) AZ_TracePrintf(AssetProcessor::DebugChannel, "JobTrace =>JobCompleted(%i %s,%s,%s)\n", rcJob, rcJob->GetJobEntry().m_databaseSourceName.toUtf8().constData(), rcJob->GetPlatformInfo().m_identifier.c_str(), rcJob->GetJobKey().toUtf8().constData()); #endif - beginRemoveRows(QModelIndex(), aznumeric_caster(jobIndex), aznumeric_caster(jobIndex)); + beginRemoveRows(QModelIndex(), jobIndex, jobIndex); m_jobs.erase(m_jobs.begin() + jobIndex); endRemoveRows(); diff --git a/Code/Tools/AssetProcessor/native/utilities/ByteArrayStream.cpp b/Code/Tools/AssetProcessor/native/utilities/ByteArrayStream.cpp index 187c872e08..4a7128be88 100644 --- a/Code/Tools/AssetProcessor/native/utilities/ByteArrayStream.cpp +++ b/Code/Tools/AssetProcessor/native/utilities/ByteArrayStream.cpp @@ -52,7 +52,6 @@ namespace AssetProcessor SizeType finalPosition = GenericStream::ComputeSeekPosition(bytes, mode); AZ_Assert(finalPosition < INT_MAX, "Overflow of SizeType to int in ByteArrayStream."); - AZ_Assert(finalPosition >= 0, "underflow in seek in ByteArrayStream"); AZ_Assert(finalPosition <= m_activeArray->size(), "You cant seek beyond end of file"); // safety clamp! diff --git a/Code/Tools/AssetProcessor/native/utilities/assetUtils.cpp b/Code/Tools/AssetProcessor/native/utilities/assetUtils.cpp index 5e005c117d..72a036bdaa 100644 --- a/Code/Tools/AssetProcessor/native/utilities/assetUtils.cpp +++ b/Code/Tools/AssetProcessor/native/utilities/assetUtils.cpp @@ -72,11 +72,6 @@ namespace AssetUtilsInternal bool FileCopyMoveWithTimeout(QString sourceFile, QString outputFile, bool isCopy, unsigned int waitTimeInSeconds) { - if (waitTimeInSeconds < 0) - { - AZ_Warning("Asset Processor", waitTimeInSeconds >= 0, "Invalid timeout specified by the user"); - waitTimeInSeconds = 0; - } bool failureOccurredOnce = false; // used for logging. bool operationSucceeded = false; QFile outFile(outputFile); diff --git a/Code/Tools/Standalone/Source/Driller/AreaChart.cpp b/Code/Tools/Standalone/Source/Driller/AreaChart.cpp index fef31aaaf3..a0eccc7d45 100644 --- a/Code/Tools/Standalone/Source/Driller/AreaChart.cpp +++ b/Code/Tools/Standalone/Source/Driller/AreaChart.cpp @@ -173,10 +173,7 @@ namespace AreaChart void AreaChart::ConfigureVerticalAxis(QString label, unsigned int minimumHeight) { - if (minimumHeight >= 0) - { - SetMinimumValueRange(minimumHeight); - } + SetMinimumValueRange(minimumHeight); if (m_verticalAxis == nullptr) { @@ -323,7 +320,7 @@ namespace AreaChart // Need to handle the areas right at the edge of the polygons for (int i = -1; i <= 1; ++i) { - if ((counter+i) < 0 || (counter + i) >= m_hitAreas.size()) + if ((counter + i) >= m_hitAreas.size()) { continue; } diff --git a/Gems/AWSGameLift/Code/AWSGameLiftClient/Source/Activity/AWSGameLiftCreateSessionActivity.cpp b/Gems/AWSGameLift/Code/AWSGameLiftClient/Source/Activity/AWSGameLiftCreateSessionActivity.cpp index 16d0cf4241..0332ea7a76 100644 --- a/Gems/AWSGameLift/Code/AWSGameLiftClient/Source/Activity/AWSGameLiftCreateSessionActivity.cpp +++ b/Gems/AWSGameLift/Code/AWSGameLiftClient/Source/Activity/AWSGameLiftCreateSessionActivity.cpp @@ -90,7 +90,7 @@ namespace AWSGameLift { auto gameliftCreateSessionRequest = azrtti_cast(&createSessionRequest); - return gameliftCreateSessionRequest && gameliftCreateSessionRequest->m_maxPlayer >= 0 && + return gameliftCreateSessionRequest && (!gameliftCreateSessionRequest->m_aliasId.empty() || !gameliftCreateSessionRequest->m_fleetId.empty()); } } // namespace CreateSessionActivity diff --git a/Gems/AWSGameLift/Code/AWSGameLiftClient/Source/Activity/AWSGameLiftCreateSessionOnQueueActivity.cpp b/Gems/AWSGameLift/Code/AWSGameLiftClient/Source/Activity/AWSGameLiftCreateSessionOnQueueActivity.cpp index 1ac9c7db1c..52be365ea5 100644 --- a/Gems/AWSGameLift/Code/AWSGameLiftClient/Source/Activity/AWSGameLiftCreateSessionOnQueueActivity.cpp +++ b/Gems/AWSGameLift/Code/AWSGameLiftClient/Source/Activity/AWSGameLiftCreateSessionOnQueueActivity.cpp @@ -79,7 +79,7 @@ namespace AWSGameLift auto gameliftCreateSessionOnQueueRequest = azrtti_cast(&createSessionRequest); - return gameliftCreateSessionOnQueueRequest && gameliftCreateSessionOnQueueRequest->m_maxPlayer >= 0 && + return gameliftCreateSessionOnQueueRequest && !gameliftCreateSessionOnQueueRequest->m_queueName.empty() && !gameliftCreateSessionOnQueueRequest->m_placementId.empty(); } } // namespace CreateSessionOnQueueActivity diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/SphericalHarmonics/SphericalHarmonicsUtility.inl b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/SphericalHarmonics/SphericalHarmonicsUtility.inl index fb1e70b2a0..7446d2fa8f 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/SphericalHarmonics/SphericalHarmonicsUtility.inl +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/SphericalHarmonics/SphericalHarmonicsUtility.inl @@ -499,7 +499,7 @@ namespace AZ // outSH -> output SH coefficient array void EvalSHRotationFast(const float R[9], const uint32_t maxBand, const float* inSH, float* outSH) { - if (maxBand >= 0 && maxBand <= 2) + if (maxBand <= 2) { ZHF3(R, maxBand, inSH, outSH); } @@ -514,10 +514,7 @@ namespace AZ // outSH -> output SH coefficient array void EvalSHRotation(const float R[9], const uint32_t maxBand, const double* inSH, double* outSH) { - if (maxBand >= 0) - { - WignerD(R, maxBand, inSH, outSH); - } + WignerD(R, maxBand, inSH, outSH); } // Fast evaluation for first 3 bands diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Shader/ShaderVariantTreeAsset.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Shader/ShaderVariantTreeAsset.cpp index bd0cad9f4d..b4a0e2e068 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Shader/ShaderVariantTreeAsset.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Shader/ShaderVariantTreeAsset.cpp @@ -199,7 +199,6 @@ namespace AZ if ((shaderVariantId.m_mask & option.GetBitMask()).any()) { optionValues.push_back(option.DecodeBits(shaderVariantId.m_key)); - AZ_Assert(optionValues.back() >= 0, "Invalid shader variant key"); } else { diff --git a/Gems/Atom/Utils/Code/Include/Atom/Utils/ImGuiGpuProfiler.inl b/Gems/Atom/Utils/Code/Include/Atom/Utils/ImGuiGpuProfiler.inl index e6bde136f8..eb5a5cea10 100644 --- a/Gems/Atom/Utils/Code/Include/Atom/Utils/ImGuiGpuProfiler.inl +++ b/Gems/Atom/Utils/Code/Include/Atom/Utils/ImGuiGpuProfiler.inl @@ -834,8 +834,10 @@ namespace AZ { // Check whether it should be sorted by name. const uint32_t sortType = static_cast(m_sortType); + AZ_PUSH_DISABLE_WARNING(4296, "-Wunknown-warning-option") bool sortByName = (sortType >= static_cast(ProfilerSortType::Alphabetical) && (sortType < static_cast(ProfilerSortType::AlphabeticalCount))); + AZ_POP_DISABLE_WARNING if (ImGui::Selectable("Pass Names", sortByName)) { @@ -1011,7 +1013,7 @@ namespace AZ const uint32_t countNumerical = static_cast(count); const uint32_t offset = static_cast(m_sortType) - startNumerical; - if (offset < countNumerical && offset >= 0u) + if (offset < countNumerical) { // Change the sorting order. m_sortType = static_cast(((offset + 1u) % countNumerical) + startNumerical); diff --git a/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/AnimGraphConnectionCommands.cpp b/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/AnimGraphConnectionCommands.cpp index b6a3870073..8396ad7b83 100644 --- a/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/AnimGraphConnectionCommands.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/AnimGraphConnectionCommands.cpp @@ -497,13 +497,13 @@ namespace CommandSystem } // verify port ranges - if (m_sourcePort >= static_cast(sourceNode->GetOutputPorts().size()) || m_sourcePort < 0) + if (m_sourcePort >= static_cast(sourceNode->GetOutputPorts().size())) { outResult = AZStd::string::format("The output port number is not valid for the given node. Node '%s' only has %zu output ports.", sourceNode->GetName(), sourceNode->GetOutputPorts().size()); return false; } - if (m_targetPort >= static_cast(targetNode->GetInputPorts().size()) || m_targetPort < 0) + if (m_targetPort >= static_cast(targetNode->GetInputPorts().size())) { outResult = AZStd::string::format("The input port number is not valid for the given node. Node '%s' only has %zu input ports.", targetNode->GetName(), targetNode->GetInputPorts().size()); return false; diff --git a/Gems/EMotionFX/Code/MCore/Source/StringConversions.cpp b/Gems/EMotionFX/Code/MCore/Source/StringConversions.cpp index c6b84a9e04..88a22db245 100644 --- a/Gems/EMotionFX/Code/MCore/Source/StringConversions.cpp +++ b/Gems/EMotionFX/Code/MCore/Source/StringConversions.cpp @@ -30,7 +30,7 @@ namespace MCore // find the last letter index from the right size_t lastIndex = AZStd::string::npos; const size_t numCharacters = prefixString.size(); - for (size_t i = numCharacters - 1; i >= 0; --i) + for (int i = static_cast(numCharacters) - 1; i >= 0; --i) { if (!AZStd::is_digit(prefixString[i])) { diff --git a/Gems/GraphModel/Code/Tests/TestEnvironment.cpp b/Gems/GraphModel/Code/Tests/TestEnvironment.cpp index 67d2e7af80..b7724c6799 100644 --- a/Gems/GraphModel/Code/Tests/TestEnvironment.cpp +++ b/Gems/GraphModel/Code/Tests/TestEnvironment.cpp @@ -51,7 +51,7 @@ namespace GraphModelIntegrationTest GraphModel::DataTypePtr TestGraphContext::GetDataType(GraphModel::DataType::Enum typeEnum) const { - if (0 <= typeEnum && typeEnum < m_dataTypes.size()) + if (typeEnum < m_dataTypes.size()) { return m_dataTypes[typeEnum]; } diff --git a/Gems/LandscapeCanvas/Code/Source/Editor/Core/GraphContext.cpp b/Gems/LandscapeCanvas/Code/Source/Editor/Core/GraphContext.cpp index 9011a82069..615139333c 100644 --- a/Gems/LandscapeCanvas/Code/Source/Editor/Core/GraphContext.cpp +++ b/Gems/LandscapeCanvas/Code/Source/Editor/Core/GraphContext.cpp @@ -102,7 +102,7 @@ namespace LandscapeCanvas GraphModel::DataTypePtr GraphContext::GetDataType(GraphModel::DataType::Enum typeEnum) const { - if (0 <= typeEnum && typeEnum < m_dataTypes.size()) + if (typeEnum < m_dataTypes.size()) { return m_dataTypes[typeEnum]; } diff --git a/Gems/Maestro/Code/Source/Cinematics/AnimPostFXNode.cpp b/Gems/Maestro/Code/Source/Cinematics/AnimPostFXNode.cpp index 9da32d757a..39e84d24a7 100644 --- a/Gems/Maestro/Code/Source/Cinematics/AnimPostFXNode.cpp +++ b/Gems/Maestro/Code/Source/Cinematics/AnimPostFXNode.cpp @@ -294,7 +294,7 @@ unsigned int CAnimPostFXNode::GetParamCount() const //----------------------------------------------------------------------------- CAnimParamType CAnimPostFXNode::GetParamType(unsigned int nIndex) const { - if (nIndex >= 0 && nIndex < (int)m_pDescription->m_nodeParams.size()) + if (nIndex < m_pDescription->m_nodeParams.size()) { return m_pDescription->m_nodeParams[nIndex].paramType; } diff --git a/Gems/Maestro/Code/Source/Cinematics/AnimScreenFaderNode.cpp b/Gems/Maestro/Code/Source/Cinematics/AnimScreenFaderNode.cpp index 62cffcefb1..975e31d8cb 100644 --- a/Gems/Maestro/Code/Source/Cinematics/AnimScreenFaderNode.cpp +++ b/Gems/Maestro/Code/Source/Cinematics/AnimScreenFaderNode.cpp @@ -304,7 +304,7 @@ unsigned int CAnimScreenFaderNode::GetParamCount() const //----------------------------------------------------------------------------- CAnimParamType CAnimScreenFaderNode::GetParamType(unsigned int nIndex) const { - if (nIndex >= 0 && nIndex < (int)s_screenFaderNodeParams.size()) + if (nIndex < s_screenFaderNodeParams.size()) { return s_screenFaderNodeParams[nIndex].paramType; } diff --git a/Gems/Maestro/Code/Source/Cinematics/CommentNode.cpp b/Gems/Maestro/Code/Source/Cinematics/CommentNode.cpp index fc58b91723..98bfef78a0 100644 --- a/Gems/Maestro/Code/Source/Cinematics/CommentNode.cpp +++ b/Gems/Maestro/Code/Source/Cinematics/CommentNode.cpp @@ -120,7 +120,7 @@ unsigned int CCommentNode::GetParamCount() const //----------------------------------------------------------------------------- CAnimParamType CCommentNode::GetParamType(unsigned int nIndex) const { - if (nIndex >= 0 && nIndex < (int)s_nodeParameters.size()) + if (nIndex < s_nodeParameters.size()) { return s_nodeParameters[nIndex].paramType; } diff --git a/Gems/Maestro/Code/Source/Cinematics/LayerNode.cpp b/Gems/Maestro/Code/Source/Cinematics/LayerNode.cpp index 8c518f5a54..e2a9e816c6 100644 --- a/Gems/Maestro/Code/Source/Cinematics/LayerNode.cpp +++ b/Gems/Maestro/Code/Source/Cinematics/LayerNode.cpp @@ -144,7 +144,7 @@ unsigned int CLayerNode::GetParamCount() const //----------------------------------------------------------------------------- CAnimParamType CLayerNode::GetParamType(unsigned int nIndex) const { - if (nIndex >= 0 && nIndex < (int)s_nodeParams.size()) + if (nIndex < (int)s_nodeParams.size()) { return s_nodeParams[nIndex].paramType; } diff --git a/Gems/Maestro/Code/Source/Cinematics/MaterialNode.cpp b/Gems/Maestro/Code/Source/Cinematics/MaterialNode.cpp index 08d4d92e8b..74b0fb1063 100644 --- a/Gems/Maestro/Code/Source/Cinematics/MaterialNode.cpp +++ b/Gems/Maestro/Code/Source/Cinematics/MaterialNode.cpp @@ -180,7 +180,7 @@ unsigned int CAnimMaterialNode::GetParamCount() const ////////////////////////////////////////////////////////////////////////// CAnimParamType CAnimMaterialNode::GetParamType(unsigned int nIndex) const { - if (nIndex >= 0 && nIndex < (int)s_nodeParams.size()) + if (nIndex < s_nodeParams.size()) { return s_nodeParams[nIndex].paramType; } diff --git a/Gems/Maestro/Code/Source/Cinematics/SceneNode.cpp b/Gems/Maestro/Code/Source/Cinematics/SceneNode.cpp index d4b894dc92..79841e671b 100644 --- a/Gems/Maestro/Code/Source/Cinematics/SceneNode.cpp +++ b/Gems/Maestro/Code/Source/Cinematics/SceneNode.cpp @@ -260,7 +260,7 @@ unsigned int CAnimSceneNode::GetParamCount() const ////////////////////////////////////////////////////////////////////////// CAnimParamType CAnimSceneNode::GetParamType(unsigned int nIndex) const { - if (nIndex >= 0 && nIndex < (int)s_nodeParams.size()) + if (nIndex < s_nodeParams.size()) { return s_nodeParams[nIndex].paramType; } diff --git a/Gems/Maestro/Code/Source/Cinematics/ShadowsSetupNode.cpp b/Gems/Maestro/Code/Source/Cinematics/ShadowsSetupNode.cpp index fd5e30199e..817c37483e 100644 --- a/Gems/Maestro/Code/Source/Cinematics/ShadowsSetupNode.cpp +++ b/Gems/Maestro/Code/Source/Cinematics/ShadowsSetupNode.cpp @@ -87,7 +87,7 @@ unsigned int CShadowsSetupNode::GetParamCount() const //----------------------------------------------------------------------------- CAnimParamType CShadowsSetupNode::GetParamType(unsigned int nIndex) const { - if (nIndex >= 0 && nIndex < (int)ShadowSetupNode::s_shadowSetupParams.size()) + if (nIndex < ShadowSetupNode::s_shadowSetupParams.size()) { return ShadowSetupNode::s_shadowSetupParams[nIndex].paramType; } diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/NodeFunctionGeneric.h b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/NodeFunctionGeneric.h index e9586ac83a..90acd4fdc9 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/NodeFunctionGeneric.h +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/NodeFunctionGeneric.h @@ -104,7 +104,9 @@ namespace ScriptCanvas private:\ static AZStd::string_view GetName(size_t i)\ {\ + AZ_PUSH_DISABLE_WARNING(4296, "-Wunknown-warning-option")\ static_assert(s_numArgs <= s_numNames, "Number of arguments is greater than number of names in " #NODE_NAME );\ + AZ_POP_DISABLE_WARNING\ /*static_assert(s_numResults <= s_numNames, "Number of results is greater than number of names in " #NODE_NAME );*/\ /*static_assert((s_numResults + s_numArgs) == s_numNames, "Argument name count + result name count != name count in " #NODE_NAME );*/\ static const AZStd::array s_names = {{ __VA_ARGS__ }};\ diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/NodeableNodeOverloaded.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/NodeableNodeOverloaded.cpp index 92039d3394..58af3a75de 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/NodeableNodeOverloaded.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/NodeableNodeOverloaded.cpp @@ -575,7 +575,7 @@ namespace ScriptCanvas const SlotExecution::Map* slotExecutionMap = GetSlotExecutionMap(); const auto& executionIns = slotExecutionMap->GetIns(); - if (methodIndex < 0 || methodIndex >= executionIns.size()) + if (methodIndex >= executionIns.size()) { return; } @@ -655,7 +655,7 @@ namespace ScriptCanvas AZ::Outcome NodeableNodeOverloaded::IsValidConfiguration(size_t methodIndex, const DataIndexMapping& inputMapping, const DataIndexMapping& outputMapping) { - if (methodIndex < 0 || methodIndex >= m_methodConfigurations.size()) + if (methodIndex >= m_methodConfigurations.size()) { return AZ::Failure(AZStd::string("Trying to access unknown method index.")); } @@ -716,7 +716,7 @@ namespace ScriptCanvas const SlotExecution::Map* slotExecutionMap = GetSlotExecutionMap(); const auto& executionIns = slotExecutionMap->GetIns(); - if (methodIndex < 0 || methodIndex >= executionIns.size()) + if (methodIndex >= executionIns.size()) { return AZ::Failure(AZStd::string("Invalid method index given to Nodeable"));; } @@ -785,7 +785,7 @@ namespace ScriptCanvas return AZ::Success(); } - if (methodIndex < 0 || methodIndex >= m_methodConfigurations.size()) + if (methodIndex >= m_methodConfigurations.size()) { return AZ::Failure(AZStd::string("Invalid Method index given to Nodeable Node Overloaded.")); } @@ -826,7 +826,7 @@ namespace ScriptCanvas { static const DataTypeSet k_emptySet; - if (methodIndex >= 0 && methodIndex < m_methodSelections.size()) + if (methodIndex < m_methodSelections.size()) { const OverloadConfiguration& overloadConfiguration = m_methodConfigurations[methodIndex]; size_t startIndex = NodeableNodeOverloadedCpp::AdjustForHiddenNodeableThisPointer(overloadConfiguration, 0); @@ -845,7 +845,7 @@ namespace ScriptCanvas return AZ::Success(); } - if (methodIndex < 0 || methodIndex >= m_methodConfigurations.size()) + if (methodIndex >= m_methodConfigurations.size()) { return AZ::Failure(AZStd::string("Invalid Method index given to Nodeable Node Overloaded.")); } @@ -883,7 +883,7 @@ namespace ScriptCanvas { static const DataTypeSet k_emptySet; - if (methodIndex >= 0 && methodIndex < m_methodSelections.size()) + if (methodIndex < m_methodSelections.size()) { return m_methodSelections[methodIndex].FindPossibleInputTypes(index); } diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/SubgraphInterface.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/SubgraphInterface.cpp index 9d1626fb73..5a88036a0f 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/SubgraphInterface.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/SubgraphInterface.cpp @@ -37,7 +37,7 @@ namespace SubgraphInterfaceCpp AZ_INLINE const char* GetTabs(size_t tabs) { - AZ_Assert(tabs >= 0 && tabs <= k_maxTabs, "invalid argument to GetTabs"); + AZ_Assert(tabs <= k_maxTabs, "invalid argument to GetTabs"); static const char* const k_tabs[] = { diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/String/StringGenerics.h b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/String/StringGenerics.h index b3a4faae30..d5ee52cdb1 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/String/StringGenerics.h +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/String/StringGenerics.h @@ -34,7 +34,7 @@ namespace ScriptCanvas { length = AZ::GetClamp(length, 0, aznumeric_cast(sourceString.size())); - if (length == 0 || index < 0 || index >= sourceString.size()) + if (length == 0 || index >= sourceString.size()) { return {}; } diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Translation/TranslationUtilities.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Translation/TranslationUtilities.cpp index 7c03102a71..a9ca526373 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Translation/TranslationUtilities.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Translation/TranslationUtilities.cpp @@ -30,7 +30,7 @@ namespace TranslationUtilitiesCPP AZ_INLINE const char* GetTabs(size_t tabs) { - AZ_Assert(tabs >= 0 && tabs <= k_maxTabs, "invalid argument to GetTabs"); + AZ_Assert(tabs <= k_maxTabs, "invalid argument to GetTabs"); static const char* const k_tabs[] = { diff --git a/Gems/ScriptEvents/Code/Include/ScriptEvents/Internal/BehaviorContextBinding/ScriptEventBroadcast.cpp b/Gems/ScriptEvents/Code/Include/ScriptEvents/Internal/BehaviorContextBinding/ScriptEventBroadcast.cpp index c55495efad..1e5e741b5d 100644 --- a/Gems/ScriptEvents/Code/Include/ScriptEvents/Internal/BehaviorContextBinding/ScriptEventBroadcast.cpp +++ b/Gems/ScriptEvents/Code/Include/ScriptEvents/Internal/BehaviorContextBinding/ScriptEventBroadcast.cpp @@ -111,7 +111,7 @@ namespace ScriptEvents { // Iterate from end of parameters and count the number of consecutive valid BehaviorValue objects size_t numDefaultArguments = 0; - for (size_t i = GetNumArguments() - 1; i >= 0 && GetDefaultValue(i); --i, ++numDefaultArguments) + for (int i = static_cast(GetNumArguments()) - 1; i >= 0 && GetDefaultValue(static_cast(i)); --i, ++numDefaultArguments) { } return GetNumArguments() - numDefaultArguments; diff --git a/Gems/ScriptEvents/Code/Include/ScriptEvents/Internal/BehaviorContextBinding/ScriptEventMethod.cpp b/Gems/ScriptEvents/Code/Include/ScriptEvents/Internal/BehaviorContextBinding/ScriptEventMethod.cpp index 37f437670d..7153fda8bd 100644 --- a/Gems/ScriptEvents/Code/Include/ScriptEvents/Internal/BehaviorContextBinding/ScriptEventMethod.cpp +++ b/Gems/ScriptEvents/Code/Include/ScriptEvents/Internal/BehaviorContextBinding/ScriptEventMethod.cpp @@ -121,7 +121,7 @@ namespace ScriptEvents { // Iterate from end of parameters and count the number of consecutive valid BehaviorValue objects size_t numDefaultArguments = 0; - for (size_t i = GetNumArguments() - 1; i >= 0 && GetDefaultValue(i); --i, ++numDefaultArguments) + for (int i = static_cast(GetNumArguments()) - 1; i >= 0 && GetDefaultValue(static_cast(i)); --i, ++numDefaultArguments) { } return GetNumArguments() - numDefaultArguments; diff --git a/cmake/Platform/Common/MSVC/Configurations_msvc.cmake b/cmake/Platform/Common/MSVC/Configurations_msvc.cmake index 0119f8d8bc..9353e4eb1c 100644 --- a/cmake/Platform/Common/MSVC/Configurations_msvc.cmake +++ b/cmake/Platform/Common/MSVC/Configurations_msvc.cmake @@ -39,11 +39,11 @@ ly_append_configurations_options( # Enabling warnings that are disabled by default from /W4 # https://docs.microsoft.com/en-us/cpp/preprocessor/compiler-warnings-that-are-off-by-default?view=vs-2019 - # /we4296 # 'operator': expression is always false + /we4296 # 'operator': expression is always false # /we4426 # optimization flags changed after including header, may be due to #pragma optimize() # /we4464 # relative include path contains '..' # /we4619 # #pragma warning: there is no warning number 'number' - # /we4777 # 'function' : format string 'string' requires an argument of type 'type1', but variadic argument number has type 'type2' looks useful + # /we4777 # 'function' : format string 'string' requires an argument of type 'type1', but variadic argument number has type 'type2' # /we5031 # #pragma warning(pop): likely mismatch, popping warning state pushed in different file # /WE5032 # detected #pragma warning(push) with no corresponding #pragma warning(pop)