Examples of errors detected by the V534 diagnostic
V534. It is possible that a wrong variable is compared inside the 'for' operator. Consider inspecting 'X'.
Source Engine SDK
V534 It is likely that a wrong variable is being compared inside the 'for' operator. Consider reviewing 'i'. Client (HL2) beamdraw.cpp 592
void DrawTeslaSegs(....)
{
int i;
....
for ( i = 0; i < segments; i++ )
{
....
for ( int j = 0; i < iBranches; j++ )
{
curSeg.m_flWidth *= 0.5;
}
....
}
....
}
Similar errors can be found in some other places:
- V534 It is likely that a wrong variable is being compared inside the 'for' operator. Consider reviewing 'i'. Client (HL2) beamdraw.cpp 622
Coin3D
V534 It is likely that a wrong variable is being compared inside the 'for' operator. Consider reviewing 'i'. element.cpp 996
cc_xml_elt *
cc_xml_elt_create_x(cc_xml_elt * from, cc_xml_path * path)
{
....
int i;
for ( i = 0; i < length; i++ ) {
....
int child;
for (child = 0; i < current->children.getLength(); child++)
{
....
}
Oracle VM Virtual Box
V534 It is likely that a wrong variable is being compared inside the 'for' operator. Consider reviewing 'i'. vboxdispd3d.cpp 4470
static HRESULT APIENTRY vboxWddmDDevCreateResource(....)
{
....
for (UINT i = 0; i < pResource->SurfCount; ++i)
{
....
if (SUCCEEDED(hr))
{
....
}
else
{
for (UINT j = 0; i < j; ++j)
{
....
}
break;
}
}
....
}
The error is probably in the "i < j" condition. I think the programmer actually wanted to write j < I.
.NET CoreCLR
V534 It is likely that a wrong variable is being compared inside the 'for' operator. Consider reviewing 'i'. ildasm mdinfo.cpp 1421
void MDInfo::DisplayFields(mdTypeDef inTypeDef,
COR_FIELD_OFFSET *rFieldOffset,
ULONG cFieldOffset)
{
....
for (ULONG i = 0; i < count; i++, totalCount++)
{
....
for (ULONG iLayout = 0; i < cFieldOffset; ++iLayout) // <=
{
if (RidFromToken(rFieldOffset[iLayout].ridOfField) ==
RidFromToken(fields[i]))
{
....
}
}
}
....
}
Android
V534 CWE-691 It is likely that a wrong variable is being compared inside the 'for' operator. Consider reviewing 'i'. AudioPolicyManager.cpp 2489
status_t AudioPolicyManager::registerPolicyMixes(....)
{
....
for (size_t i = 0; i < mixes.size(); i++) {
....
for (size_t j = 0; i < mHwModules.size(); j++) { // <=
if (strcmp(AUDIO_HARDWARE_MODULE_ID_REMOTE_SUBMIX,
mHwModules[j]->mName) == 0
&& mHwModules[j]->mHandle != 0) {
rSubmixModule = mHwModules[j];
break;
}
....
}
....
}
Similar errors can be found in some other places:
- V534 CWE-691 It is likely that a wrong variable is being compared inside the 'for' operator. Consider reviewing 'i'. AudioPolicyManager.cpp 2586
Azure Service Fabric
V534 CWE-691 It is likely that a wrong variable is being compared inside the 'for' operator. Consider reviewing 'ix0'. RvdLoggerVerifyTests.cpp 2395
NTSTATUS
ReportLogStateDifferences(....)
{
....
for (ULONG ix0=0; ix0 < RecoveredState._NumberOfStreams; ix0++)
{
KWString streamId(....);
ULONG ix1;
for (ix1 = 0; ix0 < LogState._NumberOfStreams; ix1++)
{
....
}
....
}
....
}
NCBI Genome Workbench
V534 It is likely that a wrong variable is being compared inside the 'for' operator. Consider reviewing 'i'. taxFormat.cpp 569
void CTaxFormat::x_LoadTaxTree(void)
{
....
for(size_t i = 0; i < alignTaxids.size(); i++) {
int tax_id = alignTaxids[i];
....
for(size_t j = 0; i < taxInfo.seqInfoList.size(); j++) {
SSeqInfo* seqInfo = taxInfo.seqInfoList[j];
seqInfo->taxid = newTaxid;
}
....
}
....
}
Qalculate!
V534 It is likely that a wrong variable is being compared inside the 'for' operator. Consider reviewing 'i'. MathStructure.cc 28741
bool MathStructure::isolate_x_sub(....)
{
....
for(size_t i = 0; i < mvar->size(); i++) {
if((*mvar)[i].contains(x_var)) {
mvar2 = &(*mvar)[i];
if(mvar->isMultiplication()) {
for(size_t i2 = 0; i < mvar2->size(); i2++) {
if((*mvar2)[i2].contains(x_var)) {mvar2 = &(*mvar2)[i2]; break;}
}
}
break;
}
}
....
}