14.10 Hiding an else if construct - Printable Version +- MISRA Discussion Forums (https://forum.misra.org.uk) +-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4) +--- Forum: MISRA-C: 2004 rules (https://forum.misra.org.uk/forumdisplay.php?fid=17) +---- Forum: 6.14 Control Flow (https://forum.misra.org.uk/forumdisplay.php?fid=46) +---- Thread: 14.10 Hiding an else if construct (/showthread.php?tid=579) |
14.10 Hiding an else if construct - brian_bassil - 10-09-2008 The following Code: if ( x < 0 ) Can be coded as Code: if ( x < 0 ) to hide the "else if". Is this OK? I think the code blocks are semantically identical but the last one does not list the else. Brian Re: 14.10 Hiding an else if construct - misra-c - 12-09-2008 Your implementation makes it clear to a reviewer that there are only two paths associated with the test of x and is acceptable. The intent of Rule 14.10 is to catch instances where the final else of an if ... else if ... chain has been accidently omitted. |