[OT] NULL versus 0 ( [PATCH] Use NULL instead of integer 0 in security/selinux/)

[OT] NULL versus 0 ( [PATCH] Use NULL instead of integer 0 in security/selinux/)

Post by Kari Hurtt » Fri, 09 Jul 2004 21:50:09


-- Start of PGP signed section.

(This is is off topic, because kernel is not C++, but C).

Some quotations from Bjarne Stroustrup: The C++ Programming Language
(Third Edition),

p. 843: Note that a pointer to function or a pointer to member
cannot be implicity converted to a void *.

p. 844: A constant expression (.5) that evaluates to 0 can
be implicitly converted to any pointer or pointer
to member type (.1.1.).


p. 88: In C, it has been popular to define a macro NULL to
represent the zero pointer. Because of C++'s tighter
type checking, the use of plain 0, rather than any
suggested NULL macro, leads to fewer problems. If you
feel you must define NULL, use

const int NULL = 0;

(typos mine.)

/ Kari Hurtta
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to XXXX@XXXXX.COM
More majordomo info at http://www.yqcomputer.com/
Please read the FAQ at http://www.yqcomputer.com/
 
 
 

[OT] NULL versus 0 ( [PATCH] Use NULL instead of integer 0 in security/selinux/)

Post by Michael Bu » Fri, 09 Jul 2004 21:50:10

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

That's all OK, fine and correct, but
#define NULL 0
would work for both, C and C++ as far as I can see.
Am I missing some special case?


Quoting Kari Hurtta <hurtta+ XXXX@XXXXX.COM >:

- --
Regards Michael Buesch [ http://www.yqcomputer.com/ ]


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

iD8DBQFA7UEvFGK1OIvVOP4RAua2AKCCwyC3TzasTBCbPQLaKaU47UJEbACZAY4P
wd6n6AvSuJ+ThZE/Msbs9x0=
=jvQR
-----END PGP SIGNATURE-----
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to XXXX@XXXXX.COM
More majordomo info at http://www.yqcomputer.com/
Please read the FAQ at http://www.yqcomputer.com/

 
 
 

[OT] NULL versus 0 ( [PATCH] Use NULL instead of integer 0 in security/selinux/)

Post by Herbert X » Sat, 10 Jul 2004 00:30:18


In that case NULL is wrong anyway since not all pointers are equivalent.
You need to cast 0 or NULL to the exact pointer type required by that
function.
--
Visit Openswan at http://www.yqcomputer.com/
Email: Herbert Xu ~{PmV>HI~} < XXXX@XXXXX.COM >
Home Page: http://www.yqcomputer.com/ ~herbert/
PGP Key: http://www.yqcomputer.com/ ~herbert/pubkey.txt
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to XXXX@XXXXX.COM
More majordomo info at http://www.yqcomputer.com/
Please read the FAQ at http://www.yqcomputer.com/