[MPlayer-dev-eng] [PATCH] libvo: GGI driver update
Zoltan Hidvegi
mplayer at hzoli.2y.net
Thu Sep 8 23:34:11 CEST 2005
Christoph Egger wrote:
> "if (arg)" is wrong, because it compares against the _number_ != 0,
> but arg is a pointer. See below.
No zero is special, see C99 6.3.2.3.3:
An integer constant expression with the value 0, or such an
expression cast to type void *, is called a null pointer constant...
if (arg) is not wrong. The C++ standard is more clear about this, as it
type-converts to bool and there are clear rules about the conversion. It
seems that C99 just says it's the same as (arg != 0), but by the above
paragraph, 0 is clearly a legal null pointer constant. Off topic, but in
C++ NULL is often just #define to 0 because (void*)0 cannot be implicitly
converted to other pointer types.
> I already experienced many bugs that caused stack and
> heap corruption just by mixing up pointers with numbers
> - in particular on 64bit platforms.
Yes, but not this one.
> > It's not a bug unless it can possibly lead to wrong behavior.
>
> My understanding of what is a bug is more restrictive:
if (arg) is a very common C idiom. IMO if (arg != NULL) is not any
easier to read than if (arg).
Zoli
More information about the MPlayer-dev-eng
mailing list