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
@@ -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);