
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
80 lines
1.5 KiB
Plaintext
80 lines
1.5 KiB
Plaintext
== Why is this an issue?
|
|
|
|
Unused function parameters are often due to design changes and can lead to mismatched parameter lists.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,cpp]
|
|
----
|
|
class A
|
|
{
|
|
public:
|
|
virtual void f ( uint16_t * para1, int16_t unusedpara ) = 0; // Noncompliant, unusedpara not used in any of the overriding functions.
|
|
};
|
|
|
|
class B1: public A
|
|
{
|
|
public:
|
|
virtual void f ( uint16_t * para1, int16_t unusedpara ) // Noncompliant, unusedpara not used in any of the overriding functions.
|
|
{
|
|
*para1 = 1U;
|
|
}
|
|
};
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,cpp]
|
|
----
|
|
class A
|
|
{
|
|
public:
|
|
virtual void f ( uint16_t * para1 ) = 0; // Compliant, all parameters used at least once in an overriding function.
|
|
};
|
|
|
|
class B1: public A
|
|
{
|
|
public:
|
|
virtual void f ( uint16_t * para1 ) // Compliant, all parameters used at least once in an overriding function.
|
|
{
|
|
*para1 = 1U;
|
|
}
|
|
};
|
|
----
|
|
|
|
|
|
== Resources
|
|
|
|
* MISRA {cpp}:2008, 0-1-12 - There shall be no unused parameters (named or unnamed) in the set of parameters for a virtual function and all the functions that override it.
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Remove the unused parameter 'xxx'.
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== relates to: S1172
|
|
|
|
=== on 16 Oct 2014, 12:15:46 Ann Campbell wrote:
|
|
\[~freddy.mallet] relates to RSPEC-1172
|
|
|
|
=== on 16 Oct 2014, 12:20:42 Ann Campbell wrote:
|
|
\[~samuel.mercier] please:
|
|
|
|
* fill in the appropriate reference field(s).
|
|
* provide a See section.
|
|
|
|
endif::env-github,rspecator-view[]
|