Versions Compared

Key

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

...

This recommendation is a specific case of guideline MSC12-C. Detect and remove code that has no effect.

...

In this example, 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 guideline rule DCL30-C. Declare objects with appropriate storage durations.)

...

This example can be corrected many different ways, depending on the intent of the programmer. In this compliant solution, p2 is found to be extraneous. The calls to bar() and baz() can be removed if they do not produce any side effects.

...

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

Related Guidelines

CERT C++ Secure Coding Standard: MSC13-CPP. Detect and remove unused values

Bibliography

unmigrated-wiki-markup

\[[Coverity 2007|AA. Bibliography#Coverity 07]\] \[[ISO/IEC PDTR 24772|AA. Bibliography#ISO/IEC PDTR 24772]\] TR 24772 "BRS Leveraging human experience," "KOA Likely incorrect expressions," "XYQ Dead and Deactivated Code," and "XYR Unused Variable"

Bibliography

Wiki Markup
\[[Coverity 2007|AA. Bibliography#Coverity 07]\]

...

MSC12-C. Detect and remove code that has no effect      49. Miscellaneous (MSC)