![]() |
|
MISRA-C:2004 Rule 12.5: (Required) |
|
||||
![]() | |||||||
For example write:
if((x==0)&&ishigh)/* make x == 0 primary */if(x||y||z)/* exception allowed, if x, y and z are Boolean */if(x||(y&&z))/* make y && z primary */if(x&&(!y))/* make !y primary */if((is_odd(y))&&x)/* make call primary */
Where an expression consists of either a sequence of only logical && or a sequence of only logical ||, extra parentheses are not required.
if((x>c1)&&(y>c2)&&(z>c3))/* Compliant */if((x>c1)&&(y>c2)||(z>c3))/* not compliant */if((x>c1)&&((y>c2)||(z>c3)))/* Compliant extra () used */
Note that this rule is a special case of Guideline .
QAC messages that encompass this guideline:
| 3398 | Extra parentheses recommended. A function call, array subscript, or member operation is the operand of a logical && or ||. |
| 3399 | Extra parentheses recommended. A unary operation is the operand of a logical && or ||. |
| 3400 | Extra parentheses recommended. A binary operation is the operand of a logical && or ||. |
|
||
(c) The Motor Industry Research Association, 2004
|
QA C Source Code Analyser 8.1.2
MISRA-C:2004 Compliance Module 3.2 © 2013 Programming Research www.programmingresearch.com |
Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index | Contents |