Rule 2.2 dead code and empty function

Moderators: misra-c, david ward

Post Reply
xiangke
Posts: 9
Joined: Tue Apr 11, 2017 7:34 am
Company: valeo

Rule 2.2 dead code and empty function

Post by xiangke » Mon Jun 26, 2017 6:59 am

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?

misra-c
Posts: 548
Joined: Thu Jan 05, 2006 1:11 pm

Re: Rule 2.2 dead code and empty function

Post by misra-c » Thu Sep 21, 2017 12:56 pm

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.
---
Posted by and on behalf of
the MISRA C Working Group

Post Reply

Return to “8.2 Unused code”