]> git.karo-electronics.de Git - linux-beck.git/commitdiff
drivers/vfio: Rework offsetofend()
authorGavin Shan <gwshan@linux.vnet.ibm.com>
Fri, 30 May 2014 17:35:54 +0000 (11:35 -0600)
committerAlex Williamson <alex.williamson@redhat.com>
Fri, 30 May 2014 17:35:54 +0000 (11:35 -0600)
The macro offsetofend() introduces unnecessary temporary variable
"tmp". The patch avoids that and saves a bit memory in stack.

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
include/linux/vfio.h

index 81022a52bc34dcf13cdbcca401a44b5595abfdf6..8ec980b5e3aff753cb5aae0c9cd098503cbad7a7 100644 (file)
@@ -86,9 +86,8 @@ extern void vfio_unregister_iommu_driver(
  * from user space.  This allows us to easily determine if the provided
  * structure is sized to include various fields.
  */
-#define offsetofend(TYPE, MEMBER) ({                           \
-       TYPE tmp;                                               \
-       offsetof(TYPE, MEMBER) + sizeof(tmp.MEMBER); })         \
+#define offsetofend(TYPE, MEMBER) \
+       (offsetof(TYPE, MEMBER) + sizeof(((TYPE *)0)->MEMBER))
 
 /*
  * External user API