REVIEW: #define NODEV NULL (kernel only)

From: Poul-Henning Kamp <phk_at_phk.freebsd.dk>
Date: Sat, 07 Feb 2004 18:22:47 +0100
I am inching my way towards reference counted dev_t's in the kernel,
and part of this is to allow make_dev() to fail if we are short on
resources.

To that end I would really like to get rid of the magic definition of
NODEV that we use in the kernel (which I belive is not even kosher C ?),
and simply substitute a NULL for a non-existent dev_t.

Any objections to this patch ?

Poul-Henning

Index: sys/param.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/param.h,v
retrieving revision 1.178
diff -u -r1.178 param.h
--- sys/param.h	30 Jan 2004 13:43:51 -0000	1.178
+++ sys/param.h	7 Feb 2004 17:07:48 -0000
_at__at_ -189,10 +189,12 _at__at_
 #define	NBPW	sizeof(int)	/* number of bytes per word (integer) */
 
 #define	CMASK	022		/* default file mask: S_IWGRP|S_IWOTH */
-#define	NODEV	(dev_t)(-1)	/* non-existent device */
 #ifdef _KERNEL
+#define	NODEV	NULL
 #define	NOUDEV	(udev_t)(-1)	/* non-existent device */
 #define	NOMAJ	256		/* non-existent device */
+#else
+#define	NODEV	(dev_t)(-1)
 #endif
 
 #define	CBLOCK	128		/* Clist block size, must be a power of 2. */
-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk_at_FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
Received on Sat Feb 07 2004 - 08:22:49 UTC

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