The presence of unused values may indicate significant logic errors. To prevent such errors, unused values should be identified and removed from code.
This recommendation is a specific case of \[[MSC12-A. Detect and remove code that has no effect]\]. Wiki Markup
Non-Compliant Code Example
In this example, {{ Wiki Markup p2
}} is assigned the value returned by {{bar()
}}, but that value is never used. Note this example assumes that {{foo()
}} and {{bar()
}} return valid pointers (see \[[DCL30-C. Declare objects with appropriate storage durations]\]).
Code Block | ||
---|---|---|
| ||
int *p1, *p2; p1 = foo(); p2 = bar(); if (baz()) { return p1; } else { p2 = p1; } return p2; |
...