RED-unused-param
Synopsis
A function parameter is declared but not used.
Enabled by default
No
Severity/Certainty
Low/Medium

Full description
A function parameter is declared but not used. This might be intentional, and is not unsafe as such. For example, the function might need to follow a specific calling convention, or might be a virtual C++ function that does not need as much information from its arguments as other functions do. Make sure that it is not an error. This check is identical to MISRAC++2008-0-1-11, MISRAC2012-Rule-2.7, MISRAC++2023-0.2.2_a.
Coding standards
- CWE 563
Unused Variable
- MISRA C:2012 Rule-2.7
(Advisory) There should be no unused parameters in functions
- 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;
}