![]() |
![]() |
2740 | ![]() |
||||
![]() | |||||||
| Invariant operations | |||||||
This message is generated when the controlling expression of an iteration statement (while, do-while or for) is a constant expression with a non-zero (i.e. 'true') value. This, of course, will form an infinite loop construct unless the loop is terminated with a 'break' statement or a non-returning function such as 'exit()' or 'abort()'. For example:
/*PRQA S 0769,2017,2212,3120,3140,3323,3408,3447,3602 ++*/
extern int g;
void fort1(void)
{
for (;1;) /* 2740 2870 */
{
;
}
}
void fort2(void)
{
for (;;) /* 2870 */
{
;
}
}
void fort3(void)
{
for (;1;) /* 2740 */
{
if (g < 0)
break;
}
}
void wht1(void)
{
while (1) /* 2740 2870 */
{
;
}
}
void wht2(void)
{
while (1) /* 2740 */
{
if (g < 0)
break;
}
}
void dot1(void)
{
do /* 2870 */
{
;
} while (1); /* 2740 */
}
void dot2(void)
{
do /* */
{
if (g < 0)
break;
} while (1); /* 2740 */
}
See also:
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |