The variable's value is assigned but never used, making it a dead store.
Extended Description
It is likely that the variable is simply vestigial, but it is also possible that the unused variable points out a bug.
Time of Introduction
Implementation
Common Consequences
Scope
Effect
Other
Technical Impact: Quality degradation
This weakness could be an indication of a bug in the program or a
deprecated variable that was not removed and is an indication of poor
quality. This could lead to further bugs and the introduction of
weaknesses.
Demonstrative Examples
Example 1
The following code excerpt assigns to the variable r and then
overwrites the value without using it.
(Bad Code)
Example
Language: C
r = getName();
r = getNewBuffer(buf);
Potential Mitigations
Phase: Implementation
Remove unused variables from the code.
Other Notes
This variable's value is not used. After the assignment, the variable is
either assigned another value or goes out of scope.