[MPlayer-dev-eng] [PATCH] cast null pointers

Rowan James rowanj at phere.net
Thu Aug 12 18:14:53 CEST 2010


On 13/08/2010, at 1:56 AM, Edd Barrett wrote:

> Hi,
> 
> Just a small stylistic note. Null pointers for execl should be casted to
> pointer types. Pointed out to me by naddy@ (http://c-faq.com/null/null2.html):
> <>
> 
> 
> Cheers
> 
> -- 
> Best Regards
> Edd Barrett

My understanding was that this was not just a stylistic issue, as the constant 0 expression could result in incorrect handling of stdarg-style parameter lists; the parsing code may assume that all arguments are pointer-sized; which would not be the case if an integer zero was expanded when NULL was encountered - the 'not-end-of-args' test may pass and try to read another 64-bit chunk on 64-bit architectures where only the 32-bit integer existed; since the determination of number and type of passed parameters is entirely up to the called code.

However, in my experience, it's typical for NULL to expand to not '0', but '(void*)0', which would effectively implement this change anyway.

If that is not reliably, portably the case - perhaps we should use some other token, like:
#define NULL_STR (char*)0

Instead of casting at these locations.

Thoughts?


More information about the MPlayer-dev-eng mailing list