![]() |
|
MISRA-C:2004 Rule 12.6: (Advisory) |
|
||||
![]() | |||||||
Example Code:
/* PRQA S 2982 ++ */
#include "misra.h"
#include "m2cmex.h"
extern S16 test_1206( void )
{
s16r = ( s16a < s16b ) & ( s16c > s16d ); /* MISRA Violation */
s16r = ( s16a < s16b ) | ( s16c > s16d ); /* MISRA Violation */
s16r = ( s16c > s16d) * (s16a < s16b); /* MISRA Violation */
s16r = ( s16c > s16d) + s16b; /* MISRA Violation */
s16r = s16r + (s16c > s16d); /* MISRA Violation */
bla = ( s16a + s16b ) && ( s16c + s16d ); /* MISRA Violation */
bla = ( s16a + s16b ) || ( s16c + s16d ); /* MISRA Violation */
bla = ( s16a + s16b ) && ( s16c > s16d ); /* MISRA Violation */
bla = ( s16a > s16b ) && ( s16c + s16d ); /* MISRA Violation */
bla = ! ( s16a + s16b ); /* MISRA Violation */
bla = (s16a + s16b) > (s16c > s16d); /* MISRA Violation */
bla = (s16a > s16b) > (s16c + s16d); /* MISRA Violation */
bla = (s16a > s16b) > (s16c > s16d); /* MISRA Violation */
s16r = ~(s16a > s16b); /* MISRA Violation */
bla = s16a && ( s16c < s16d ); /* MISRA Violation */
bla = !s16a; /* MISRA Violation */
return s16r;
}
QAC messages that encompass this guideline:
| 3322 | Operand of a logical ! operator is a constant expression which is not a 'Boolean' value. |
| 3377 | Operand of a logical && or || operator is a constant expression which is not a 'Boolean' value. |
| 4101 | Both operands of & operator are 'Boolean' expressions. |
| 4102 | Both operands of | operator are 'Boolean' expressions. |
| 4103 | Both operands of arithmetic or bitwise operator are 'Boolean' expressions. |
| 4104 | Left hand operand of arithmetic or bitwise operator is a 'Boolean' expression. |
| 4105 | Right hand operand of arithmetic or bitwise operator is a 'Boolean' expression. |
| 4106 | Both operands of && operator are arithmetic or bitwise expressions. |
| 4107 | Both operands of || operator are arithmetic or bitwise expressions. |
| 4108 | Left hand operand of logical operator is an arithmetic or bitwise expression. |
| 4109 | Right hand operand of logical operator is an arithmetic or bitwise expression. |
| 4110 | Operand of ! operator is an arithmetic or bitwise expression. |
| 4111 | Right hand operand of relational operator is a 'Boolean' expression. |
| 4112 | Left hand operand of relational operator is a 'Boolean' expression. |
| 4113 | Both operands of relational operator are 'Boolean' expressions. |
| 4114 | Operand of ~ operator is a 'Boolean' expression. |
| 4115 | Operand of logical && or || operator is not an 'essentially Boolean' expression. |
| 4116 | Operand of logical ! operator is not an 'essentially Boolean' expression. |
|
||
(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 |