hi, On Mon, Jan 24, 2011 at 8:11 PM, Gustavo Lopes <glo...@nebm.ist.utl.pt> wrote:
> Hum? Pierre's change is "correct", but it's also redundant. It is not redundant. It can even help some compilers or analyzer. > Please read the C FAQ: http://c-faq.com/null/ptrtest.html > > What would be invalid would be testing for a null pointer with something > like this: > > void *p; > ... > int a = 0; > if (p == (void*)a) { } > > Because "a" is not "a constant integer expression with value 0" (not to > mention, integer to pointer conversions are implementation defined). A NULL > pointer doesn't have to be represented with address 0x0, but a *constant* 0 > is guaranteed to represent a NULL pointer constant. Also doing so (testing a == NULL instead of !a) is a common and widely adopted practice (like testing return values from malloc/realloc but that's another topic). The fact is that our code base is full of bad things, while they may be legal, they may not be correct per se, or not good practice. Maybe it is due to the PHP-like way of implementing extensions... Now can we move on? Freaking amazing to see so much bandwidth wasted for one line change, which was not even the main part of that commit. Cheers, -- Pierre @pierrejoye | http://blog.thepimp.net | http://www.libgd.org -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php