Erroneous compiler warnings in NNDK Rel23 RC7a

Topics for the Eclipse Environment
Post Reply
nurquhar
Posts: 8
Joined: Mon May 12, 2008 8:52 pm

Erroneous compiler warnings in NNDK Rel23 RC7a

Post 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") ;
}
User avatar
yevgenit
Posts: 84
Joined: Fri Apr 25, 2008 12:47 am
Contact:

Re: Erroneous compiler warnings in NNDK Rel23 RC7a

Post 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.
Yevgeni Tunik
Embedded/RealTime software engineer
https://www.linkedin.com/in/yevgenitunik/
________________________
Post Reply