]> 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)
committerWilly Tarreau <w@1wt.eu>
Fri, 10 Feb 2017 10:03:41 +0000 (11:03 +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>
[wt: backported only for ipv6 out-of-bounds fix]

Signed-off-by: Willy Tarreau <w@1wt.eu>
include/linux/vfio.h

index ac8d488e4372d32e2136a3c673dc0e105d5320b9..1a7f0acf891bd18270242d21f36f662ffe15d909 100644 (file)
@@ -86,8 +86,7 @@ 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))
 
 #endif /* VFIO_H */