Re: [PATCH] tools/nolibc: avoid using plain integer as NULL pointer
From: David Laight
Date: Mon Nov 10 2025 - 07:22:15 EST
On Sun, 9 Nov 2025 20:57:54 +0100
Willy Tarreau <w@xxxxxx> wrote:
> Hi Thomas,
>
> On Sun, Nov 09, 2025 at 08:27:29PM +0100, Thomas Weißschuh wrote:
> > The integer zero should not be used as NULL pointer.
> > It is invalid and sparse will complain about it.
> >
> > Use proper NULL pointers instead.
>
> Huh ? I've been using that for decades and seeing it everywhere. That's
> quite bizarre, 0 is perfectly valid as a pointer. Ah, here it is, in
> C99:6.3.2.3:
>
> An integer constant expression with the value 0, or such an expression
> cast to type void *, is called a null pointer constant.
Note also that the above is true even if the value stored in memory for
a NULL point isn't the 'all zero' bit pattern.
The only time it actually matters whether you use 0 or NULL is in varargs
function calls.
Even that is dependant on the calling convention (when NULL is zero).
David