![]() |
![]() |
2212 | ![]() |
||||
![]() | |||||||
| Bracing and Indentation | |||||||
The 'body' of this if, for, while or do while statement is not a compound statement, i.e. it is not enclosed in braces { }. Although, it is perfectly legal to write code in this way, there are potential dangers. In the absence of braces, the 'body' of the control statement will always be just a single statement; but it is easy to be misled by the way in which subsequent code is arranged. Two messages address this problem.
/*PRQA S 2017,2201,2205,3227,3408 ++*/
extern void foo(int n)
{
int x = 0;
int y = 0;
if (n > 0)
++x; /* Message 2212 */
++y;
if (n > 0) ++x; ++y; /* Message 2214 */
if (n > 0)
{
++x; /* OK */
++y;
}
}
See also:
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |