From: David Laight <david.laight.linux@gmail.com>
To: Willy Tarreau <w@1wt.eu>
Cc: "Thomas Weißschuh" <linux@weissschuh.net>,
linux-kernel@vger.kernel.org, "kernel test robot" <lkp@intel.com>
Subject: Re: [PATCH] tools/nolibc: avoid using plain integer as NULL pointer
Date: Mon, 10 Nov 2025 12:16:22 +0000 [thread overview]
Message-ID: <20251110121622.3a8e4a40@pumpkin> (raw)
In-Reply-To: <20251109195754.GB20023@1wt.eu>
On Sun, 9 Nov 2025 20:57:54 +0100
Willy Tarreau <w@1wt.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
prev parent reply other threads:[~2025-11-10 12:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-09 19:27 [PATCH] tools/nolibc: avoid using plain integer as NULL pointer Thomas Weißschuh
2025-11-09 19:57 ` Willy Tarreau
2025-11-09 20:27 ` Thomas Weißschuh
2025-11-10 12:16 ` David Laight [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251110121622.3a8e4a40@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=lkp@intel.com \
--cc=w@1wt.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox