Examples of errors detected by the V529 diagnostic
V529. Suspicious semicolon ';' after 'if/for/while' operator.
Xpdf
V529 Odd semicolon ';' after 'if' operator. AFPDFLib queue.h 66
BOOL AddTail(LPVOID p)
{
....
if(queue.GetSize() >= this->_limit);
{
while(queue.GetSize() > this->_limit-1)
{
::WaitForSingleObject(handles[SemaphoreIndex], 1);
queue.Delete(0);
}
}
....
}
Multi-threaded Dynamic Queue
V529 Odd semicolon ';' after 'while' operator. StandardQueues mtqueueproducer.cpp 35
void CMTQueueProducer::Reset()
{
void* pMsg = NULL;
CSimpleMessage* pDecodedMsg = NULL;
while(TheQueueBuffer::GetInstance()->Pop(pMsg));
{
pDecodedMsg = (CSimpleMessage*) pMsg;
if (pDecodedMsg)
{
try { delete pDecodedMsg; } catch (....) { NULL; }
}
pMsg = NULL;
}
}
Fennec Media
V529 Odd semicolon ';' after 'for' operator. settings.c 483
int settings_default(void)
{
....
for(i=0; i<16; i++);
for(j=0; j<32; j++)
{
settings.conversion.equalizer_bands.boost[i][j] = 0.0;
settings.conversion.equalizer_bands.preamp[i] = 0.0;
}
}
Fennec Media
V529 Odd semicolon ';' after 'for' operator. settings.c 913
int trans_rest(transcoder_settings *trans)
{
....
for(i=0; i<16; i++);
{
trans->eq.eq.preamp[i] = 0.0;
for(j=0; j<32; j++)
{
trans->eq.eq.boost[i][j] = 0.0;
}
}
}
ReactOS
V529 Odd semicolon ';' after 'if' operator. tdi events.c 126
BOOLEAN
CTEScheduleEvent(PCTE_DELAYED_EVENT Event,
PVOID Context)
{
....
if (!Event->Queued);
{
Event->Queued = TRUE;
Event->Context = Context;
ExQueueWorkItem(&Event->WorkItem, CriticalWorkQueue);
}
....
}
Similar errors can be found in some other places:
- V529 Odd semicolon ';' after 'if' operator. ntoskrnl mdlsup.c 1177
CamStudio
V529 Odd semicolon ';' after 'for' operator. boundary.c 3100
psd_static void psd_art_svp_render_aa_iter_step(....)
{
....
/* move cursor to topmost vector which overlaps [y,y+1) */
for(curs = 0; seg->points[curs + 1].y < y; curs++);
cursor[i] = curs;
....
}
ReactOS
V529 Odd semicolon ';' after 'for' operator. environ.c 67
int BlockEnvToEnvironA(void)
{
....
for (envptr--; envptr >= _environ; envptr--);
free(*envptr);
....
}
Similar errors can be found in some other places:
- V529 Odd semicolon ';' after 'for' operator. environ.c 119
- V529 Odd semicolon ';' after 'for' operator. environ.c 171
Windows 8 Driver Samples
V529 Odd semicolon ';' after 'if' operator. hw_mac.c 95
NDIS_STATUS
HwSetPowerMgmtMode(....)
{
....
if (!HW_MULTIPLE_MAC_ENABLED(Hw) &&
(PMMode->dot11PowerMode != dot11_power_mode_unknown));
{
NdisMoveMemory(&Hw->MacState.PowerMgmtMode,
PMMode, sizeof(DOT11_POWER_MGMT_MODE));
HalSetPowerMgmtMode(Hw->Hal, PMMode);
}
....
}
QuickThread
V529 Odd semicolon ';' after 'if' operator. quickthread.cpp 670
QuickThreadCallNodeQueue* getCallNodeQueue(Affinities_bm& bm)
{
....
if(temp->owningThreadNumber < 0);
temp->owningThreadNumber = 0;
....
}
VirtualDub
V529 Odd semicolon ';' after 'while' operator. VirtualDub crash.cpp 462
static ModuleInfo *CrashGetModules(void *&ptr) {
....
while(*pszHeap++);
if (pszHeap[-1]=='.')
period = pszHeap-1;
....
}
Oracle VM Virtual Box
V529 Odd semicolon ';' after 'for' operator. server_getshaders.c 92
void
SERVER_DISPATCH_APIENTRY crServerDispatchGetAttachedShaders(....)
{
....
for (i=0; i<*pLocal; ++i); // <=
ids[i] = crStateGLSLShaderHWIDtoID(ids[i]);
....
}
Haiku Operation System
V529 Odd semicolon ';' after 'for' operator. ringqueue.cpp 39
int
compute_order(unsigned long size)
{
int order;
unsigned long tmp;
for (order = 0, tmp = size; tmp >>= 1; ++order); // <=
if (size & ~(1 << order))
++order;
return order;
}
Bizarre formatting, but the code works. I guess they wanted to show their best here, but it just didn't work out quite well. This loop calculates the value of the highest set order. That is, the original number is shifted until it equals to zero ((tmp >>= 1), and the number of iterations is calculated (++order). for (order = 0, tmp = size; tmp >>= 1; ++order); And this code if (size & ~(1 << order)) ++order; rounds it up. Basically, it's ceil(log2(N)), a common construction used for calculating the number of bits necessary for encoding N different elements.
MAME
V529 Odd semicolon ';' after 'if' operator. win32ui.c 2300
static BOOL GameCheck(void)
{
....
i = ListView_FindItem(hwndList, -1, &lvfi);
if (changed && i != -1); // <=
ListView_RedrawItems(hwndList, i, i);
if ((game_index % progBarStep) == 0)
ProgressBarStep();
game_index++;
....
}
Similar errors can be found in some other places:
- V529 Odd semicolon ';' after 'if' operator. win32ui.c 2876
CryEngine V
V529 Odd semicolon ';' after 'for' operator. boolean3d.cpp 1314
int CTriMesh::Slice(....)
{
....
bop_meshupdate *pmd = new bop_meshupdate, *pmd0;
pmd->pMesh[0]=pmd->pMesh[1] = this; AddRef();AddRef();
for(pmd0=m_pMeshUpdate; pmd0->next; pmd0=pmd0->next); // <=
pmd0->next = pmd;
....
}
GuiLite
V529 Odd semicolon ';' after 'while' operator. GuiLite.h 3413
#define CORRECT(x, high_limit, low_limit) {\
x = (x > high_limit) ? high_limit : x;\
x = (x < low_limit) ? low_limit : x;\
}while(0)
void refresh_wave(unsigned char frame)
{
....
CORRECT(y_min, m_wave_bottom, m_wave_top);
....
}