Skip to content

Commit

Permalink
drivers/vfio: Rework offsetofend()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Gavin Shan authored and Alex Williamson committed May 30, 2014
1 parent c8dbca1 commit b13460b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions include/linux/vfio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b13460b

Please sign in to comment.