MSCXX-A. Detect and remove code that has no effect
Code that does not perform any action, or has an unintended effect can result in unexpected behavior and vulnerabilities. Statements or expressions that have no effect should be identified and removed from code.
...
Code Block | ||
---|---|---|
| ||
int a;
a == b;
/* ... */
|
This is likely a case of the programmer mistakenly using the equals operator ==
instead of the assignment operator =
.
...
Code Block | ||
---|---|---|
| ||
int a;
a = b;
/* ... */
|
Non-Compliant Code Example 2
...
Code Block | ||
---|---|---|
| ||
int *p;
*p++;
|
Compliant Solution 2
Dereferencing p
has no effect and should not be dereferenced.
...