<<< Date Index >>>     <<< Thread Index >>>

Re: [PATCH] Use NULL in vararg



On Mon, Nov 08, 2004 at 05:04:58PM +0100, Ralf Wildenhues wrote:
> -     snprintf (buf, buflen, fmt, Context ? Context->pattern : 0);
> +     snprintf (buf, buflen, fmt, Context ? Context->pattern : NULL);
>
> Use NULL as null pointer in status_format_str in order to be 64bit
> clean.  (Strictly ANSI-C speaking, one would have to do (void*)0
> or (void*)NULL here, but in practice, this is sufficient).

Humm.... two things:

1) NULL ought to be (void *)0 - in the old days it might have just been 0,
   but given the compiler knows about 'void *', then (void *)0 is good.

2) The two posible result of a ? : clause have to have the same type,
   so the type of 'x ? "" : 0' is always 'const char *'.

so it matters not whether the code uses NULL or 0.

There is also the vague possiblilty that NULL is #defined to something else!

        David

-- 
David Laight: david@xxxxxxxxx