Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Feb 2017 14:13:36 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r313810 - head/sys/compat/linuxkpi/common/include/linux
Message-ID:  <201702161413.v1GEDaMX052720@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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]))



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