MISRA Discussion Forums
Rule 2.2 dead code and empty function - 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:2012 and MISRA C:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=21)
+---- Forum: 8.2 Unused code (https://forum.misra.org.uk/forumdisplay.php?fid=157)
+---- Thread: Rule 2.2 dead code and empty function (/showthread.php?tid=1353)



Rule 2.2 dead code and empty function - xiangke - 26-06-2017

An empty function is the dead code? for example:
/*file1.c*/
void vidNextStep(void)
{

}
/*file2.c*/
void test(void)
{
vidNextStep();
}
I think an empty function is the dead code, because it shall be called, it means that it shall execute, but It shall not affect program behavior.
Do it?


Re: Rule 2.2 dead code and empty function - misra-c - 21-09-2017

This example is the same as the last example for rule 2.2 in the document.

Function vidNextStep is compliant with rule 2.2 because there are no operations that can be removed within the function.
However, the call of vidNextStep is non compliant with rule 2.2 as the call can be removed without any change in the program behaviour.