svn commit: r301038 - head/sys/sys

Ed Schouten ed at FreeBSD.org
Tue May 31 13:32:34 UTC 2016


Author: ed
Date: Tue May 31 13:32:33 2016
New Revision: 301038
URL: https://svnweb.freebsd.org/changeset/base/301038

Log:
  Make CMSG_*() work without having NULL available.
  
  The <sys/socket.h> is not supposed to declare NULL, according to POSIX.
  Our implementation complies with that, meaning that we need to make sure
  that CMSG_*() doesn't use it.

Modified:
  head/sys/sys/socket.h

Modified: head/sys/sys/socket.h
==============================================================================
--- head/sys/sys/socket.h	Tue May 31 13:31:19 2016	(r301037)
+++ head/sys/sys/socket.h	Tue May 31 13:32:33 2016	(r301038)
@@ -500,7 +500,7 @@ struct sockcred {
 
 /* given pointer to struct cmsghdr, return pointer to next cmsghdr */
 #define	CMSG_NXTHDR(mhdr, cmsg)	\
-	((char *)(cmsg) == NULL ? CMSG_FIRSTHDR(mhdr) : \
+	((char *)(cmsg) == (char *)0 ? CMSG_FIRSTHDR(mhdr) : \
 	    ((char *)(cmsg) + _ALIGN(((struct cmsghdr *)(cmsg))->cmsg_len) + \
 	  _ALIGN(sizeof(struct cmsghdr)) > \
 	    (char *)(mhdr)->msg_control + (mhdr)->msg_controllen) ? \
@@ -515,7 +515,7 @@ struct sockcred {
 #define	CMSG_FIRSTHDR(mhdr) \
 	((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
 	 (struct cmsghdr *)(mhdr)->msg_control : \
-	 (struct cmsghdr *)NULL)
+	 (struct cmsghdr *)0)
 
 #if __BSD_VISIBLE
 /* RFC 2292 additions */


More information about the svn-src-head mailing list