RED-unused-assign
In this section:
Synopsis
A variable is assigned a non-trivial value that is never used.
Enabled by default
Yes
Severity/Certainty
Low/Medium

Full description
A variable is assigned a non-trivial value that is never used. This is not unsafe as such, but might indicate a logical error.
Coding standards
- CERT MSC13-C
Detect and remove unused values
- CWE 563
Unused Variable
Code examples
The following code example fails the check and will give a warning:
int example(void) {
int x;
x = 20;
x = 3;
return 0;
}
The following code example passes the check and will not give a warning about this issue:
int example(void) {
int x;
x = 20;
return x;
}