>
>
>
V2537. MISRA. Functions should not have…


V2537. MISRA. Functions should not have unused parameters.

This diagnostic rule is based on the software development guidelines developed by MISRA (Motor Industry Software Reliability Association).

Unused function parameters frequently appear after code refactoring. The function signature does not match its implementation, it's difficult to immediately find out if it is a programmer's error.

Let's consider the example:

static bool CardHasLock(int width, int height)
{
  const double xScale = 0.051; 
  const double yScale = 0.0278; 

  int lockWidth  = (int)floor(width * xScale);
  int lockHeight = (int)floor(width * yScale);
  ....
}

From the code you can see that the 'height' parameter was never used in the body of the function. Most likely, there is an error and the initialization of the 'lockHeight' variable has to be as follows:

int lockHeight = (int)floor(height * yScale);

This diagnostic is classified as:

  • MISRA-C-2.7
  • MISRA-CPP-0.1.11