![]() |
![]() |
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 behavior, 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 */
}
}
See also:
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |