Page 1 of 1

Erroneous compiler warnings in NNDK Rel23 RC7a

Posted: Sun Aug 16, 2009 11:14 pm
by nurquhar
I am getting some warnings for errors which don't exist.

For example in this function it warns me that iLed is an unused variable :!: Yet it is clearly assigned in the initialisation of the 'for' loop and accessed in the body.

Code: Select all

// Clear Screen to background colour
void CPanelCfg::ClearScreenBg()
{
	int iLed ;
	long offset ;
	for(int driver = 0, iLed = 0 ; driver < iPanels ; driver++, iLed+=(iLedsPerPanel*3)) {
		offset = HEADER_DL + ((long)iLed * IVALSIZE) ;
		for(int i = 0 ; i < iLedsPerPanel ; i++, offset += IVALSIZE) {
			// Set the background colour at the point
			pDst->SetAt(offset+iBitOffsetR, bg.r) ;
			pDst->SetAt(offset+iBitOffsetG, bg.g) ;
			pDst->SetAt(offset+iBitOffsetB, bg.b) ;
		}
	}
}
In this function it reports that 'n' may be an uninitialised variable :!: Even though I have used an explict assignment on line 11.

Code: Select all

void CMemAppend::Dump()
{
	BYTE *p = GetBuffer() ;
	int e = (int)GetSize() ;
	int n ;
	int ll = 0x0F ;
	char ch ;

	printf("CMemAppend::Dump()\n") ;
	n = 0 ;
	for(int i = 0 ; i < e ; i++, p++) {
		n = i & ll ;
		if(n == 0)
			printf("%04X:", i) ;
		ch = *p ;
		if(ch >= 0x20 && ch < 0x7f) {
			printf("%c", ch) ;
		} else {
			printf("(%02x)", (int)ch) ;
		}
		if(n == ll)
			printf("\n") ;
	}
	if(n != ll)
		printf("\n") ;
}

Re: Erroneous compiler warnings in NNDK Rel23 RC7a

Posted: Mon Aug 17, 2009 12:59 am
by yevgenit
Replace the fragment
int iLed ;
long offset ;
for(int driver = 0, iLed = 0 ; driver < iPanels ; driver++, iLed+=(iLedsPerPanel*3)) {

with more good-styled lines:
int iLed = 0 ;
long offset ;
for(int driver = 0 ; driver < iPanels ; driver++, iLed+=(iLedsPerPanel*3)) {

It eliminates the warning.