Re: [PATCH] Use NULL instead of integer 0 in security/selinux/

From: Michael Buesch
Date: Thu Jul 08 2004 - 06:31:33 EST


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoting "Richard B. Johnson" <root@xxxxxxxxxxxxxxxxxx>:
> Because NULL is a valid pointer value. 0 is not. If you were
> to make 0 valid, you would use "(void *)0", which is what
> NULL just happens to be in all known architectures so far,
> although that could change in an alternate universe.

No, that is not true.
In C/C++ this is true:
NULL == 0

You can _always_ use 0 instead of NULL. The use of NULL is
_only_ for readability reasons. When you assign 0 to a
pointer, the compiler knows that you want to assign a
NULL-pointer and not the value 0.
Even on architectures where the NULL-pointer is not
represented as 0 in memory (another bitmask), it's still
valid to assign 0 to a pointer, because the compiler
_knows_ that you are handling with a pointer and does
The Right Thing (tm).

- --
Regards Michael Buesch [ http://www.tuxsoft.de.vu ]


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFA7S/mFGK1OIvVOP4RAoJ4AKCVY9QbxaXEjGthqGXpoN1Wqw8bzACgwzW/
AZVhE8MYOGNwKC/k74qZUBw=
=Vy7x
-----END PGP SIGNATURE-----
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/