01-07-2007, 11:05 AM
I would suggest the following.
case 0 uses if-else. so you can catch a specific \"if\" and all esle will be the oposite state.
depending on you system your default should return an error or place the system in a safe state.
Why are you switching on X and then testing for result? I think you could have a more elegant solution.
Code:
switch(x)
{
case 0:
result = checkInitVars();
if (SUCCESS != result)
{
/* something not fine here, get out. */
}
else
{
result = startOperation();
}
break;
case 1:
result = checkInitVars();
if (SUCCESS == result)
{
result = startOperation();
}
break;
default:
result = FAILED;
break;
}
case 0 uses if-else. so you can catch a specific \"if\" and all esle will be the oposite state.
depending on you system your default should return an error or place the system in a safe state.
Why are you switching on X and then testing for result? I think you could have a more elegant solution.
<t>This post is made in a personal capacity<br/>
Member of MISRA-C-WG since 2002</t>
Member of MISRA-C-WG since 2002</t>