Enable warning MSVC 4296: 'operator': expression is always false

This commit is contained in:
Esteban Papp
2021-08-20 13:42:19 -07:00
committed by GitHub
41 changed files with 94 additions and 109 deletions
-1
View File
@@ -2634,7 +2634,6 @@ void EditorViewportWidget::ShowCursor()
//////////////////////////////////////////////////////////////////////////
void EditorViewportWidget::PushDisableRendering()
{
assert(m_disableRenderingCount >= 0);
++m_disableRenderingCount;
}
+2 -2
View File
@@ -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<int>(m_childs.size()) - 1; i >= 0; --i)
{
m_childs[i]->SetMinSpec(nSpec, true);
}
+1 -1
View File
@@ -1416,7 +1416,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);
+1 -1
View File
@@ -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<int>(m_undoSteps.size()) - 1; i >= 0; i--)
{
m_undoSteps[i]->Undo(bUndo);
}
+15 -25
View File
@@ -58,36 +58,26 @@ bool C3DConnexionDriver::InitDevice()
//Doc says RIM_TYPEHID: Data comes from an HID that is not a keyboard or a mouse.
if (m_pRawInputDeviceList[i].dwType == RIM_TYPEHID)
{
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);
}
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++;
}
}
}
+1 -1
View File
@@ -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]);
+2
View File
@@ -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)
@@ -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]);
@@ -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, 50> 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, 10> 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> 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
@@ -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);
+1 -1
View File
@@ -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<int>(m_index));
}
@@ -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<int>(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<int>(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();
@@ -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!
@@ -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);
@@ -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;
}