MISRA.FILE_PTR.DEREF.INDIRECT.2012A pointer to a FILE object (returned by a function) shall not be dereferenced. MISRA C 2012 Rule 22.5: A pointer to a FILE object shall not be dereferencedCategory: Mandatory Analysis: Undecidable, System Applies to: C90, C99 AmplificationA pointer to a FILE object shall not be dereferenced directly or indirectly (e.g. by a call to memcpy or memcmp). RationaleThe Standard (C90 Section 7.9.3(6), C99 Section 7.19.3(6) ) states that the address of a FILE object used to control a stream may be significant and a copy of the object may not give the same behaviour. This rule ensures that such a copy cannot be made. The direct manipulation of a FILE object is prohibited as this may be incompatible with its use as a stream designator. Example#include <stdio.h> FILE *pf1; FILE *pf2; FILE f3; pf2 = pf1; /* Compliant */ f3 = *pf2; /* Non-compliant */ The following example assumes that FILE * specifies a complete type with a member named pos: pf1->pos = 0; /* Non-compliant */ See alsoRule 21.6 |