Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#FFCCCC
int a;
int b;
/* ... */
a == b;

This is likely a case of the programmer mistakenly using the equals operator == instead of the assignment operator =.

...

Code Block
bgColor#ccccff
int a;
int b;
/* ... */
a = b;

Non-Compliant Code Example 2

...

Code Block
bgColor#FFCCCC
int *p;
/* ... */
*p++;

Compliant Solution 2

Correcting this example depends on the intent of the programmer. For instance, if dereferencing p was done on accident, then p should not be dereferenced.

Code Block
bgColor#ccccff
int *p;
/* ... */
p++;

Wiki Markup
If the intent was to increment the value referred to by {{p}}, then parentheses can be used to ensure {{p}} is dereferenced then incremented \[[EXP00-A. Use parentheses for precedence of operation]\].

Code Block
bgColor#ccccff
int *p;
/* ... */
(*p)++

Risk Assessment

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

...