[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251110121622.3a8e4a40@pumpkin>
Date: Mon, 10 Nov 2025 12:16:22 +0000
From: David Laight <david.laight.linux@...il.com>
To: Willy Tarreau <w@....eu>
Cc: Thomas Weißschuh <linux@...ssschuh.net>,
linux-kernel@...r.kernel.org, kernel test robot <lkp@...el.com>
Subject: Re: [PATCH] tools/nolibc: avoid using plain integer as NULL pointer
On Sun, 9 Nov 2025 20:57:54 +0100
Willy Tarreau <w@....eu> 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
Powered by blists - more mailing lists