Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added unconditional jump example

...

Code Block
bgColor#ccccff
langc
if (a == b) { 
  do_x();
}
if (a == c) { 
  do_w();
}

Noncompliant Code Example (Unconditional Jump)

Unconditional jump statements typically has no effect.  

Code Block
bgColor#FFCCCC
langc
#include <stdio.h>
 
for (int i = 0; i < 10; ++i) {
  printf("i is %d", i);
  continue;  // this is meaningless; the loop would continue anyway
}

Compliant Solution (Unconditional Jump)

The continue statement has been removed from this compliant solution.

Code Block
bgColor#ccccff
langc
#include <stdio.h>
 
for (int i = 0; i < 10; ++i) {
   printf("i is %d", i); 
}

Risk Assessment

The presence of code that has no effect can indicate logic errors that may result in unexpected behavior and vulnerabilities.

...