[previous] MISRA-C:2004  Rule  16.6:  (Required) [next] The number of arguments passed to a function shall match the number of parameters.
This problem is completely avoided by the use of function prototypes - see Rule . This rule is retained since compilers may not flag this constraint error.

Example Code:


/* PRQA S 3206 ++ */

#include "misra.h"
#include "m2cmex.h"


static S16 test_1606a( S16 i, S16 j );
static S16 test_1606b( S16 k );
static S16 test_1606c();

static S16 test_1606c( a )
S16 a;
{
   return a;
}

extern S16 test_1606( void )
{
   S16 r;

   r = test_1606a( 1 );             /* MISRA Violation */
   r += test_1606b( 1, 1 );         /* MISRA Violation */
   r += test_1606c( 1, 1 );         /* MISRA Violation */

   return r;
}

static S16 test_1606a( S16 i, S16 j )
{
   return i + j;
}

static S16 test_1606b( S16 k )
{
   return k;
}


QAC messages that encompass this guideline:

0422 [C] Function call contains fewer arguments than prototype specifies.
0423 [C] Function call contains more arguments than prototype specifies.
3319 [U] Function called with number of arguments which differs from number of parameters in definition.


Related rules:

Rule  1.1 All code shall conform to ISO/IEC 9899:1990 C programming language, ISO 9899, amended and corrected by ISO/IEC 9899/COR1:1995, ISO/IEC 9899/AMD1:1995, and ISO/IEC 9899/COR2: 1996192
Rule  1.2 No reliance shall be placed on undefined or unspecified behaviour.



(c) The Motor Industry Research Association, 2004
QA C Source Code Analyser 8.1.2
MISRA-C:2004 Compliance Module 3.2
© 2013 Programming Research
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index Contents