lkml.org 
[lkml]   [2004]   [Jul]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] Use NULL instead of integer 0 in security/selinux/
From
Date
Andrea Arcangeli <andrea@suse.de> writes:

> 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...

Well gcc is not terribly hackable that way, something about decades
of code bloat...

The thing to keep in mind is that it was the integer to pointer
conversion that needed to be hacked. (void *)0 is the null pointer
constant by definition. So you it is technically illegal in that
context to use (ptr *)0 to refer to the first page of memory. It
must be another number that you can convert and manipulate.

For a single program I do agree that it probably would not be worth it
but if you were delivering an architecture where people wrote lots
of code it would be better fix the compiler to be standards conforming.

Eric


-
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.161 / U:0.132 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site