[previous] 2463 [next] The variable incremented in the third expression of this 'for' statement is not the variable identified as the 'loop control variable' (%s).
Control flow

The variable modified in the third 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,2201,3120,3199,3203,3408 ++*/

extern void foo(int dummy)
{
  int j;

  for (j = 0; j < 10;        )             /*              */
  {
      ++j;                                 /* Message 2469 */
  }

  for (j = 0; j < 20; dummy++)             /* Message 2463 */
  {
      ++j;                                 /* Message 2469 */
  }

  for (j = 0; j < 30; dummy = dummy + 1)   /* Message 2463 */
  {
      ++j;                                 /* Message 2469 */
  }

  for (j = 100; j > 40; dummy--)           /* Message 2463 */
  {
      --j;                                 /* Message 2469 */
  }

}

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents