NULL vs 0 vs 0L bikeshed time

From: Mark Murray <mark_at_grondar.org>
Date: Sun, 29 Feb 2004 15:46:35 +0000
Hi

1) Please restrain the need to bikeshed this one to death. I am
   sympathetic to technical arguments, but compulsive noise over
   such issues is annoying.

2) Please separate style disussion from technical discussion.

I'd like to commit the following patch. It makes sure that for C
and the kernel, NULL is a ((void *)0), and for C++, NULL is either
(0L) or 0, with __LP64__ used to define the difference.

The intent is to catch use of NULL where 0 or (0L) should be used.
It generates extra warnings (I promise to fix these).

Comments?

WARNING! Cut+Paste munging!

Index: _null.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/_null.h,v
retrieving revision 1.5
diff -u -d -r1.5 _null.h
diff -u -d -r1.5 _null.h
--- _null.h     26 Dec 2003 06:11:43 -0000      1.5
+++ _null.h     26 Dec 2003 10:36:52 -0000
_at__at_ -28,14 +28,14 _at__at_

 #ifndef NULL

-#ifdef _KERNEL
-#define        NULL    (void *)0
+#if defined(_KERNEL) || !defined(__cplusplus)
+#define        NULL    ((void *)0)
 #else
 #if defined(__LP64__)
-#define        NULL    0L
+#define        NULL    (0L)
 #else
 #define        NULL    0
-#endif
-#endif /* _KERNEL */
+#endif /* __LP64__ */
+#endif /* _KERNEL || !__cplusplus */

 #endif

M
--
Mark Murray
iumop ap!sdn w,I idlaH
Received on Sun Feb 29 2004 - 06:50:20 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:45 UTC