Function prototype has parameters not read or written in function body
This defect occurs when a function parameter is neither read nor written in the function body. The checker does not flag unused parameters in functions with empty bodies.
Unused parameters can indicate that the code is possibly incomplete. The parameter is possibly intended for an operation that you forgot to code.
If the copied objects are large, redundant copies can slow down performance.
Determine if you intend to use the parameters. Otherwise, remove parameters that you do not use in the function body.
You can intentionally have unused parameters. For instance, you have parameters that you intend to use later when you add enhancements to the function. Add a code comment indicating your intention for later use. The code comment helps you or a code reviewer understand why your function has unused parameters.
Alternatively, add a statement such as (void)var; in
the function body. var is the unused parameter.
You can define a macro that expands to this statement and add the
macro to the function body.
| Group: Good practice |
| Language: C | C++ |
| Default: Off |
Command-Line Syntax: UNUSED_PARAMETER |
| Impact: Low |