Примеры ошибок, обнаруженных с помощью диагностики V1064
V1064. The left operand of integer division is less than the right one. The result will always be zero.
Ogre3D
V1064 The '1' operand of integer division is less than the '100000' one. The result will always be zero. OgreAutoParamDataSource.cpp 1094
typedef Vector<4, Real> Vector4;
const Vector4&
AutoParamDataSource::getShadowSceneDepthRange(size_t index) const
{
static Vector4 dummy(0, 100000, 100000, 1/100000);
// ....
}
Here the dummy vector should store floating point numbers. However, there are integer values to the left and right of the division operator.
RPCS3
V1064 The 'nsec' operand of the modulo operation is less than the '1000000000ull' operand. The result is always equal to the left operand. Thread.cpp 2359
void thread_ctrl::wait_for(u64 usec, [[maybe_unused]] bool alert /* true */)
{
// ....
if (!alert && usec > 0 && usec <= 1000 && fd_timer != -1)
{
struct itimerspec timeout;
u64 missed;
u64 nsec = usec * 1000ull;
timeout.it_value.tv_nsec = (nsec % 1000000000ull);
timeout.it_value.tv_sec = nsec / 1000000000ull;
timeout.it_interval.tv_sec = 0;
timeout.it_interval.tv_nsec = 0;
timerfd_settime(fd_timer, 0, &timeout, NULL);
// ....
}
}
In then-branch usec <= 1000. So nsec <= 1000'000, and nsec % 1'000'000'000 expression is meaningless.
Xenia
V1064 The 'level0_table_count' operand of integer division is less than the 'HASHES_PER_L1_HASH' one. The result will always be zero. stfs_container_device.cc 500
void StfsContainerDevice::BlockToOffsetSVOD(size_t block, ....)
{
....
const size_t BLOCKS_PER_FILE = 0x14388;
const size_t BLOCKS_PER_L0_HASH = 0x198;
const size_t HASHES_PER_L1_HASH = 0xA1C4;
....
size_t true_block = block - (BLOCK_OFFSET * 2);
....
size_t file_block = true_block % BLOCKS_PER_FILE;
size_t level0_table_count = (file_block / BLOCKS_PER_L0_HASH) + 1;
size_t level1_table_count = (level0_table_count / HASHES_PER_L1_HASH) + 1;
....
}
The 'level1_table_count' value always equals 0 because the 'level0_table_count' left operand is less than the 'HASHES_PER_L1_HASH' right operand during an integer division operation.