]> git.hungrycats.org Git - linux/commitdiff
drivers/vfio: Rework offsetofend()
authorGavin Shan <gwshan@linux.vnet.ibm.com>
Fri, 30 May 2014 17:35:54 +0000 (11:35 -0600)
committerJiri Slaby <jslaby@suse.cz>
Mon, 28 Nov 2016 21:22:31 +0000 (22:22 +0100)
commit b13460b92093b29347e99d6c3242e350052b62cd upstream.

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>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
include/linux/vfio.h

index 24579a0312a0c45dca0216d137721e0381d8c11d..43f6bf4f85850459a09396f604bacc85a790347c 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