From: Lubos Lunak <l.lunak@suse.cz>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH][RESEND] do not redefine userspace's NULL #define
Date: Fri, 13 Apr 2012 23:46:56 +0200 [thread overview]
Message-ID: <201204132346.57019.l.lunak@suse.cz> (raw)
In-Reply-To: <CA+55aFxCrVtwCd9bjHLt82Uwisp8OtKP9c+raPYMqCTXqVfxGw@mail.gmail.com>
On Friday 13 of April 2012, Linus Torvalds wrote:
> On Fri, Apr 13, 2012 at 12:24 PM, Lubos Lunak <l.lunak@suse.cz> wrote:
> > GCC's NULL is actually __null, which allows detecting some questionable
> > NULL usage and warn about it. Moreover each platform/compiler should have
> > its own stddef.h anyway (which is different from linux/stddef.h).
> > So there's no good reason to override what the compiler provides.
> > Keep the #define conditionally, in order to keep the headers
> > self-contained.
>
> There's no way user should ever include the linux internal stddef.h.
If that were the case, one of the earlier versions of the patch would have
been correct then, but as Arnd has pointed out, user applications do include
the header. It's even as simple as:
#include <signal.h>
( -> bits/sigcontext.h -> asm/sigcontext.h -> linux/types.h ->
linux/posix_types.h -> linux/stddef.h ).
> And quite frankly, kernel-external definitions of NULL have
> traditionally been pure sh*t (ie plain "0" without the cast to a
> pointer), so I'm not entirely convinced about this patch.
Quite frankly, I do not care what happens with it in kernel builds. I just
don't want the suboptimal definition to leak to userspace. If you instead
make sure linux/stddef.h is never used by userspace, that's fine with me.
> So what is the *actual* thing this helps with?
Random example:
/home/tinderbox/clang-master-build/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx:216:66:
warning: missing sentinel in function call [-Wsentinel]
GTK_CELL_LAYOUT (m_pLists[i]), pCell, "text", 0, NULL);
^
, NULL
I used the Clang compiler for the more detailed error output (and the in this
context somewhat amusing fix-it hint), but it's of course the same with GCC.
And from 'man gcc' (4.6):
-Wstrict-null-sentinel (C++ and Objective-C++ only)
Warn also about the use of an uncasted "NULL" as sentinel. When
compiling only with GCC this is a valid sentinel, as "NULL" is defined
to "__null". Although it is a null pointer constant not a null pointer, it
is guaranteed to be of the same size as a pointer. But this use is not
portable across different compilers.
--
Lubos Lunak
l.lunak@suse.cz
next prev parent reply other threads:[~2012-04-13 21:47 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-13 19:24 Lubos Lunak
2012-04-13 19:39 ` Linus Torvalds
2012-04-13 21:02 ` Arnd Bergmann
2012-04-16 7:43 ` Martin Schwidefsky
2012-04-13 21:46 ` Lubos Lunak [this message]
2012-04-14 8:28 ` Arnd Bergmann
2012-04-13 22:01 ` Peter Seebach
2012-04-13 22:24 ` Linus Torvalds
2012-04-13 23:18 ` Lubos Lunak
2012-04-14 0:44 ` Linus Torvalds
2012-04-14 6:43 ` Lubos Lunak
2012-04-14 7:51 ` Linus Torvalds
2012-04-14 8:21 ` Lubos Lunak
2012-04-14 8:27 ` Linus Torvalds
2012-04-14 8:54 ` Lubos Lunak
2012-04-14 9:30 ` Arnd Bergmann
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=201204132346.57019.l.lunak@suse.cz \
--to=l.lunak@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/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
all inboxes | Powered by JetHome®