MISRAC2012-Rule-2.7
In this section:
Synopsis
(Advisory) There should be no unused parameters in functions.
Enabled by default
No
Severity/Certainty
Low/Medium

Full description
A function parameter is declared but not used. This check is identical to RED-unused-param, MISRAC++2008-0-1-11, MISRAC++2023-0.2.2_a.
Coding standards
- CWE 563
Unused Variable
- MISRA C++ 2008 0-1-11
(Required) There shall be no unused parameters (named or unnamed) in nonvirtual functions.
- MISRA C++ 2023 0.2.2
(Required) A named function parameter shall be used at least once
Code examples
The following code example fails the check and will give a warning:
int example(int x) {
/* `x' is not used */
return 20;
}
The following code example passes the check and will not give a warning about this issue:
int example(int x) {
return x + 20;
}