Re: [PATCH] tools/nolibc: avoid using plain integer as NULL pointer
From: Thomas Weißschuh
Date: Sun Nov 09 2025 - 15:27:25 EST
On 2025-11-09 20:57:54+0100, Willy Tarreau 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.
>
> The change is small, so if it hurts sparse, I'm fine with changing it,
> but at least the commit message should be adjusted to say that sparse
> doesn't like it and not that it's not valid.
Yeah, indeed '0' is special and valid, even in C23.
My recollection was wrong. Thanks for the hint!
> > Reported-by: kernel test robot <lkp@xxxxxxxxx>
> > Closes: https://lore.kernel.org/r/202509261452.g5peaXCc-lkp@xxxxxxxxx/
> > Signed-off-by: Thomas Weißschuh <linux@xxxxxxxxxxxxxx>
>
> For the patch: Acked-by: Willy Tarreau <w@xxxxxx>
And thanks again.
Thomas