MISRAC2012-Rule-2.2_c
In this section:
Synopsis
(Required) There shall be no dead code.
Enabled by default
Yes
Severity/Certainty
Low/Medium

Full description
A variable is assigned a value that is never used. This check is identical to RED-unused-val, MISRAC++2008-0-1-6.
Coding standards
- CWE 563
Unused Variable
- MISRA C:2012 Rule-2.2
(Required) There shall be no dead code
- MISRA C++ 2008 0-1-6
(Required) A project shall not contain instances of non-volatile variables being given values that are never subsequently used.
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;
}