Versions Compared

Key

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

...

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 See guideline DCL30-C. Declare objects with appropriate storage durations.).

Code Block
bgColor#FFCCCC
int *p1, *p2;
p1 = foo();
p2 = bar();

if (baz()) {
  return p1;
}
else {
  p2 = p1;
}
return p2;

...

Recommendation

Severity

Likelihood

Remediation Cost

Priority

Level

MSC13-C

low

unlikely

medium

P2

L3

Automated Detection

The LDRA tool suite Version 7.6.0 can detect violations of this recommendation.

...

Tool

Version

Checker

Description

Section

LDRA tool suite

Include Page
c:LDRA_V
c:LDRA_V

 

 

Section

Coverity Prevent

Include Page
c:Coverity_V
c:Coverity_V
Section

UNUSED_VALUE

Section

finds variables that are assigned pointer values returned from a function call but never used

...

Section

Klocwork

Include Page
c:Klocwork_V
c:Klocwork_V

 

Section

can detect violations of this rule with a number of checkers

...

Related Vulnerabilities

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

Other Languages

Related Guidelines

This rule appears in the C++ Secure Coding Standard as : MSC13-CPP. Detect and remove unused values.

Bibliography

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

...