[previous] MISRA-C:2004  Rule  16.10:  (Required) [next] If a function returns error information, then that error information shall be tested.
A function (whether it is part of the standard library, a third party library or a user defined function) may provide some means of indicating the occurrence of an error. This may be via an error flag, some special return value or some other means. Whenever such a mechanism is provided by a function the calling program shall check for the indication of an error as soon as the function returns.

However, note that the checking of input values to functions is considered a more robust means of error prevention than trying to detect errors after the function has completed (see Rule ). Note also that the use of errno (to return error information from functions) is clumsy and should be used with care (see Rule ).

Example Code:


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

static S16 test_1610a( void );

extern S16 test_1610( void )
{
   S16 r;

   test_1610a();                       /* MISRA Violation */

   r = test_1610a();

   return r;
}

static S16 test_1610a( void )
{
   return 1;
}


QAC messages that encompass this guideline:

3200 '%s' returns a value which is not being used.



(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