svn commit: r313810 - head/sys/compat/linuxkpi/common/include/linux

Hans Petter Selasky hselasky at FreeBSD.org
Thu Feb 16 14:13:37 UTC 2017


Author: hselasky
Date: Thu Feb 16 14:13:36 2017
New Revision: 313810
URL: https://svnweb.freebsd.org/changeset/base/313810

Log:
  Allow container_of() to be used with constant data pointers.
  
  Obtained from:		kmacy @
  MFC after:		1 week
  Sponsored by:		Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/kernel.h

Modified: head/sys/compat/linuxkpi/common/include/linux/kernel.h
==============================================================================
--- head/sys/compat/linuxkpi/common/include/linux/kernel.h	Thu Feb 16 13:32:15 2017	(r313809)
+++ head/sys/compat/linuxkpi/common/include/linux/kernel.h	Thu Feb 16 14:13:36 2017	(r313810)
@@ -245,8 +245,8 @@ scnprintf(char *buf, size_t size, const 
 
 #define container_of(ptr, type, member)				\
 ({								\
-	__typeof(((type *)0)->member) *_p = (ptr);		\
-	(type *)((char *)_p - offsetof(type, member));		\
+	const __typeof(((type *)0)->member) *__p = (ptr);	\
+	(type *)((uintptr_t)__p - offsetof(type, member));	\
 })
   
 #define	ARRAY_SIZE(x)	(sizeof(x) / sizeof((x)[0]))


More information about the svn-src-all mailing list