![]() |
![]() |
2462 | ![]() |
||||
![]() | |||||||
| Control flow | |||||||
The variable initialised in the first expression of this 'for loop' does not appear to be the 'control variable'. The control variable is identified by examining the 3 'for-loop' expressions. Usually it is a variable in the 2nd expression which is the operand of a relational operator. For example:
/*PRQA S 2017,3120,3199,3203,3408 ++*/
extern void foo(void)
{
int j = 0;
int dummy;
for ( ; j < 10; j++) /* */
{
/* ... */
}
for (dummy=0; j < 20; j++) /* Message 2462 */
{
/* ... */
}
}
MISRA-C:2004 Rules applicable to message 2462:
| Rule 13.5 (Required) | The three expressions of a for statement shall be concerned only with loop control. |
![]() | ||
| QA·C Source Code Analyser 8.1
MISRA-C:2004 Compliance Module 3.2 © 2012 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index | Contents |