V
vl106
A static code analysis tool gave me a warning on
if (ptr && ptr->data) { ... }
I assumed the tool doesn't get the "short circuit behaviour" in
the if statement.
But a collegue said it may be the missing check ot ptr against
NULL.
What happens on an architecture where NULL isn't address
with all bits set to zero (e.g. 0xffff)? In this case my if-statement
will fail.
Does that mean the only portable way is "if (ptr != NULL)?.
if (ptr) and if (!ptr) would then be non-portable?
Thanks for your help.
if (ptr && ptr->data) { ... }
I assumed the tool doesn't get the "short circuit behaviour" in
the if statement.
But a collegue said it may be the missing check ot ptr against
NULL.
What happens on an architecture where NULL isn't address
with all bits set to zero (e.g. 0xffff)? In this case my if-statement
will fail.
Does that mean the only portable way is "if (ptr != NULL)?.
if (ptr) and if (!ptr) would then be non-portable?
Thanks for your help.