![]() |
|
MISRA-C:2004 Rule 13.5: (Required) |
|
||||
![]() | |||||||
First expression - Initialising the loop counter
Second expression - Shall include testing the loop counter, and optionally other loop control variables
Third expression - Increment or decrement of the loop counter
The following options are allowed:
Example Code:
#include "misra.h"
#include "m2cmex.h"
extern S16 test_1305( void )
{
S16 n;
n = 0;
for ( s16a++; n < 10; n++ ) /* MISRA Violation */
{
s16b = s16b + s16a;
}
for ( s16a = 0; ++s16a < 10; ++s16b ) /* MISRA Violation - also Rule 12.13 */
{
++s16b;
}
return s16b;
}
QAC messages that encompass this guideline:
| 2462 | The variable initialized in the first expression of this 'for' statement is not the variable identified as the 'loop control variable' (%s). |
| 2463 | The variable incremented in the third expression of this 'for' statement is not the variable identified as the 'loop control variable' (%s). |
|
||
(c) The Motor Industry Research Association, 2004
|
QA C Source Code Analyser 8.1.2
MISRA-C:2004 Compliance Module 3.2 © 2013 Programming Research www.programmingresearch.com |
Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index | Contents |