Why is the code below cited for violation of MISRA 13.6

6.13 Control Statement Expressions

Moderators: misra-c, david ward

Post Reply
kalpak
Posts: 4
Joined: Tue Aug 24, 2010 9:09 am
Company: polar systems and devices

Why is the code below cited for violation of MISRA 13.6

Post by kalpak » Thu Mar 03, 2011 9:33 am

Why is the last code line (array element initialization) in the code below being cited for 13.6 violation by Crystal Revs MISRA checker:

Code: Select all

/*Test code for Crystal revs MISRA rule 13.6 */
typedef unsigned char uint8_t
void InitArray(void);

#define LCD_NUM_OF_COLS 2u
#define LCD_NUM_OF_ROWS	10u
uint8_t Test_Array[LCD_NUM_OF_COLS][LCD_NUM_OF_ROWS];

void InitArray(void)
	{
	uint8_t row_index = 0u;
	uint8_t col_index = 0u;	
	for (col_index = 0u; col_index < LCD_NUM_OF_COLS; col_index++)
		{
		for (row_index=0u; row_index < LCD_NUM_OF_ROWS; row_index++)	
			{
			/*	make each element of the array the char NULL	*/
			Test_Array[col_index][row_index] = 0u;	
			}	
		}
	}
 
thanks,
kalpak

misra-c
Posts: 569
Joined: Thu Jan 05, 2006 1:11 pm

Re: Why is the code below cited for violation of MISRA 13.6

Post by misra-c » Mon Mar 07, 2011 4:57 pm

The code example does not appear to violate Rule 13.6. There is a missing ';' character at the end of the typedef but this would not explain the diagnostic message from your tool.

MISRA does not provide guidance on specific tools so you should contact your tool provider for an explanation.
---
Posted by and on behalf of
the MISRA C Working Group

kalpak
Posts: 4
Joined: Tue Aug 24, 2010 9:09 am
Company: polar systems and devices

Re: Why is the code below cited for violation of MISRA 13.6

Post by kalpak » Tue Mar 08, 2011 2:40 am

Thanks,
that ";" was forgotten while creating a minimum demo code to test.
And even after adding that ";", the warning persists.
Unfortunately the vendor of Crystal Revs was informed of this 2 weeks ago but they have not replied yet.

Post Reply

Return to “6.13 Control Statement Expressions”