The presence of unused values may indicate significant logic errors. To prevent such errors, unused values should be identified and removed from code.
...
Code Block | ||
---|---|---|
| ||
int *p1, *p2; p1 = foo(); p2 = bar(); if (baz()) { return p1; } else { p2 = p1; } return p2; |
Compliant Solution
...
Code Block | ||
---|---|---|
| ||
int *p1 = foo();
int *p2 = NULL;
bar(); /* Removable if bar() does not produce any side-effects */
if (baz()) {
return p1;
}
else {
p2 = p1;
}
return p2;
|
...