![]() |
![]() |
3109 | ![]() |
||||
![]() | |||||||
| Readability | REFERENCE - ISO:C90-6.6.3 Expression and Null Statements | ||||||
This null statement follows other code which is present on the same line. Is this intended ? Although null statements usually have no semantic significance, they can be be dangerous if they occur by mistake in certain contexts. The danger arises when a stray semicolon becomes the body of an if, else, for or while construct. In any other context a null statement is untidy but harmless. Danger is avoided by consistently following these control statements with a compound statement. This is a good practice to follow for other reasons also and the requirement can be enforced with messages 2212 and 2212. For example:
/* PRQA S 2201,3120,3132,3138,3139,3199,3227,3344,3408,3416,3440,3447 ++*/
extern int buf[10];
extern void foo(int n)
{
int i;
for (i = 0; i < 5; ++i); /* Message 3109 + 2214 */
buf[i] = 0;
if (n == 1); /* Message 3109 + 2214 */
buf[n] = 0;
while(--n); /* Message 3109 + 2214 */
buf[n] = 0;
n++;; /* Message 3109 */
}
See also:
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |