![]() |
![]() |
2993 | ![]() |
||||
![]() | |||||||
| Invariant operations | |||||||
The controlling expression in this 'do .. while' statement will always evaluate to zero and so the loop will therefore only be executed once. This suggests a logical flaw in the code. If this is really the intended behaviour, there are more transparent ways of achieving the same effect - e.g. by replacing the controlling expression with the value 0. For example:
/*PRQA S 2017,3204,3227,3356,3360,3408 ++*/
void foo(int i)
{
if (i == 0)
{
do
{
} while (i != 0); /* 2993 2996 */
}
}
MISRA-C:2004 Rules applicable to message 2993:
| Rule 13.7 (Required) | Boolean operations whose results are invariant shall not be permitted. |
See also:
![]() | ||
| QA·C Source Code Analyser 8.1
MISRA-C:2004 Compliance Module 3.2 © 2012 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index | Contents |