Is CERT C FIO34-C really NOT covered by MISRA rules as stated in MISRA C:2012 Addendum 3 - Printable Version +- MISRA Discussion Forums (https://forum.misra.org.uk) +-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4) +--- Forum: General Questions (https://forum.misra.org.uk/forumdisplay.php?fid=27) +--- Thread: Is CERT C FIO34-C really NOT covered by MISRA rules as stated in MISRA C:2012 Addendum 3 (/showthread.php?tid=1476) |
Is CERT C FIO34-C really NOT covered by MISRA rules as stated in MISRA C:2012 Addendum 3 - alexporto - 28-02-2019 The document MISRA:C Addendum 3 classifies the CERT C rule FIO34-C as NOT COVERED by MISRA (Coverage is None/None) However, the condition detailed in this rule FIO34-C seems to be fully covered by MISRA rule 22.7 FIO34-C: Distinguish between characters read from a file and EOF or WEOF MISRA C:2012 Amendment 1, Rule 22.7: The macro EOF shall only be compared with the unmodified return value from any Standard Library function capable of returning EOF Is that correct? Re: Is CERT C FIO34-C really NOT covered by MISRA rules as stated in MISRA C:2012 Addendum 3 - misra-c - 13-06-2019 Both rules address the issue that a value returned by getchar ( and similar functions ) may be indistinguishable from EOF. However they cover different situations. The description and examples of FIO34-C show that is concerned with the situation when int and char have the same size. Rule 22.7 is concerned with situations where the return value undergoes a type conversion if that value is then compared to EOF. The following example is non-compliant with FIO34-C, but compliant with rule 22.7 as no type conversions occur. Code: int c; |