![]() |
![]() |
3343 | ![]() |
||||
![]() | |||||||
| Arithmetic type - Operations | REFERENCE - ISO:C90-6.3.3.3 Unary Arithmetic Operators | ||||||
A logical NOT operator (!) has been applied to one operand of an equality operator (== or !=). This is a strange construct and probably a mistake. If both operands are effectively Boolean, i.e. they have values of either 0 or 1, the expression would be more readable if rewritten. For example, in the following code, if "a" and "b" are Boolean values, the "if" expression in function "f1" evaluates as true if ...
/*PRQA S 2017,3227,3408 ++*/
extern int f1(int a, int b)
{
int r = 0;
if (!a == b) /* Message 3343 */
{
r = 1;
}
return r;
}
extern int f2(int a, int b)
{
int r = 0;
if (a != b) /* OK */
{
r = 1;
}
return r;
}
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |