20-02-2009, 04:11 PM
Hi Lundin,
in this moment I am not concerned about good programming practice, but on the genuine interpretation of MISRA rules.
In particular, when y is a pointer,
is not testing a value against zero: it is testing the validity of a pointer and, as you write, this may have nothing to do with zero.
This reasoning made me think that, perhaps, there is an oversight in the example given on page 65 of MISRA-C:2004: perhaps it should read
Can the MISRA committee shed some light on this?
Thanks,
Roberto
in this moment I am not concerned about good programming practice, but on the genuine interpretation of MISRA rules.
In particular, when y is a pointer,
Code:
if ( y ) ...
This reasoning made me think that, perhaps, there is an oversight in the example given on page 65 of MISRA-C:2004: perhaps it should read
Code:
if ( y ) /* Not compliant, unless y is effectively Boolean data
(e.g. a flag) or a pointer. */
Thanks,
Roberto
<t></t>