![]() |
![]() |
3344 | ![]() |
||||
![]() | |||||||
| Control flow | |||||||
Controlling expressions appear in if, for, while or do ... while constructs and as the first operand of a conditional operator. They are expressions which always undergo an implicit test against the value '0'. However they are most readable when formed from an operator which explicitly yields a result of 0 or 1. Message 3344 is generated when a controlling expression is not formed from one of the following operators:
/*PRQA S 2017,2213,3198,3199,3203,3408,3447 ++*/
extern int a;
extern int b;
extern void foo(void)
{
int r;
if (a) { } /* Message 3344 */
while (a + b) { --a; } /* Message 3344 */
r = a ? a : b; /* Message 3344 */
if (a != 0) { } /* OK */
while (a > b) { ++b; } /* OK */
r = (a < b) ? a : b; /* OK */
}
MISRA-C:2004 Rules applicable to message 3344:
| Rule 13.2 (Advisory) | Tests of a value against zero should be made explicit, unless the operand is effectively Boolean. |
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 |