Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 29 Feb 2004 15:46:35 +0000
From:      Mark Murray <mark@grondar.org>
To:        current@freebsd.org
Subject:   NULL vs 0 vs 0L bikeshed time
Message-ID:  <200402291546.i1TFkZ0w070591@grimreaper.grondar.org>

next in thread | raw e-mail | index | archive | help
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
@@ -28,14 +28,14 @@

 #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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200402291546.i1TFkZ0w070591>