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 Thu, Jul 08, 2004 at 10:32:32AM -0400, Richard B. Johnson wrote:
> On Thu, 8 Jul 2004, P. Benie wrote:
> > the integer 0 and null pointers are not the same, the compiler will
> > perform the appropriate conversion for you, so it is always correct to
> > define NULL as (void *)0.
>
> That's NOT what is says. It states that a NULL pointer is converted to
> the appropriate type before any comparison is made. It does NOT say
> that 0 is a valid null-pointer.

0 when casted or assigned to a pointer will be converted to the null
pointer value by the compiler, that's why doing !ptr is equivalent to
ptr == NULL, even if ptr points to address 0xffffffff virtual in
reality. Still NULL is set to (void *) 0, or alternatively (void *) -1UL
(thought the latter I'm not 100% sure but I think it'll work in such a
case).

It's mostly theory though, I've never seen an arch with a compiler with
a null pointer not actually meaning virtual address 0UL (that's why we
used a C-breaking #define NULL ((void*)-1UL) once we needed it).
-
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.464 / U:0.648 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site