lkml.org 
[lkml]   [2004]   [Jul]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Use NULL instead of integer 0 in security/selinux/
On Fri, Jul 09, 2004 at 11:23:52PM -0700, Linus Torvalds wrote:
> I really don't see the point of complaining about the fixes. There's just
> _no_ way to say that "0" is more readable than "NULL" in any of the cases.
> I dare you - show _one_ case where a 0/NULL patch was wrong or even
> remotely debatable. I dare you.

I definitely agree.

Several years ago I once wrote a singificant piece of code for a projet
with #define NULL -1UL, this actually wasn't my choice but a requirement
of the project (the headers were pre-defined) but it worked perfectly
since we never did '!ptr' we always did 'ptr == NULL' instead (etc..).
So at runtime it has never been a problem because we coded with NULL !=
0 in mind. Of course I known normally NULL is always equal to 0 but I
didn't realize that defining NULL !=0 wasn't exactly the C language (I
learnt it later on the hard way in some mailing list, I believe at some
point I did patches like the one in this thread but claiming it to be a
bugfix, and not just a cleanup ;).

IIRC my argument about these patches being bugfixes, was about an
architecture with a valid page mapped at address 0, that wouldn't
generate a segfault. This is incidentally why we had to use NULL = -1
instead of NULL = 0. The answer I got at that time form some C guru is
that I would need to hack the compiler specifically for such achitecture
to accomodate for NULL = -1, so that '!ptr' will be the same as 'ptr ==
-1UL' (for pointers). In practice I think it has been a lot easier for
us to avoid using '!ptr' than to hack gcc...
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:04    [W:0.213 / U:0.252 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site