[previous] MISRA C:2012  Rule-17.2:  (Required) [next] Functions shall not call themselves, either directly or indirectly

Example Code:


#include "misra.h"
#include "m3cmex.h"

static void rule_1702a( int16_t x );
static void rule_1702b( int16_t x );
static void rule_1702c( int16_t x );
static void rule_1702d( int16_t x );
static void rule_1702e( int16_t x );

extern int16_t rule_1702( void )
{
   rule_1702a( 5 );
   rule_1702e( 5 );
   return 1;
}

static void rule_1702a( int16_t x )
{
   if ( x > 0 )
   {
      --x;
      rule_1702b( x );
   }
}

static void rule_1702b( int16_t x )
{
   if ( x > 0 )
   {
      --x;
      rule_1702c( x );
   }
}

static void rule_1702c( int16_t x )
{
   if ( x > 0 )
   {
      --x;
      rule_1702d( x );
   }
}

static void rule_1702d( int16_t x )
{
   if ( x > 0 )
   {
      --x;
      rule_1702a( x );
   }
}

static void rule_1702e( int16_t x )
{
   if ( x > 0 )
   {
      --x;
      rule_1702e( x );                          /* 3670 */
   }
}


QAC messages that encompass this guideline:

1520 Functions are indirectly recursive.
3670 Recursive call to function containing this call.



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