[previous] 2889 [next] This function has more than one 'return' path.
Control flow

This function returns in more than one place. According to structured programming principles, a function should only contain a single exit point.

Note that one of the return paths referred to in this message may be an implicit "return;" statement at the end of the function.

For example:


/*PRQA S 2006,2017,3120,3227,3408 ++*/

extern int foo(int n)                   /* 2889 */
{
   if (n > 10)
   {
      return 0;
   }

   return n;
}


MISRA C:2012 Rules applicable to message 2889:

Rule-15.5  (Advisory) A function should have a single point of exit at the end


QA·C Source Code Analyser 8.1
MISRA C:2012 Compliance Module 1.0
© 2012 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index Contents