From: Gavin Shan <gwshan@linux.vnet.ibm.com>
To: kvm@vger.kernel.org
Cc: alex.williamson@redhat.com, bhelgaas@google.com,
linux-pci@vger.kernel.org, Gavin Shan <gwshan@linux.vnet.ibm.com>
Subject: [PATCH 2/4] drivers/vfio: Rework offsetofend()
Date: Tue, 13 May 2014 11:35:22 +1000 [thread overview]
Message-ID: <1399944924-1200-3-git-send-email-gwshan@linux.vnet.ibm.com> (raw)
In-Reply-To: <1399944924-1200-1-git-send-email-gwshan@linux.vnet.ibm.com>
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>
---
include/linux/vfio.h | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/include/linux/vfio.h b/include/linux/vfio.h
index 81022a52..8ec980b 100644
--- a/include/linux/vfio.h
+++ b/include/linux/vfio.h
@@ -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
--
1.8.3.2
next prev parent reply other threads:[~2014-05-13 1:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-13 1:35 [PATCH v2 0/4] VFIO Misc fixes Gavin Shan
2014-05-13 1:35 ` [PATCH 1/4] PCI: Export MSI message relevant functions Gavin Shan
2014-05-13 1:35 ` Gavin Shan [this message]
2014-05-13 1:35 ` [PATCH 3/4] drivers/vfio/pci: Fix wrong MSI interrupt count Gavin Shan
2014-05-13 1:35 ` [PATCH 4/4] vfio/pci: Restore MSIx message prior to enabling Gavin Shan
2014-05-19 2:54 ` Gavin Shan
-- strict thread matches above, loose matches on Subject: below --
2014-05-19 3:01 [PATCH 0/4] VFIO Misc fixes Gavin Shan
2014-05-19 3:01 ` [PATCH 2/4] drivers/vfio: Rework offsetofend() Gavin Shan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1399944924-1200-3-git-send-email-gwshan@linux.vnet.ibm.com \
--to=gwshan@linux.vnet.ibm.com \
--cc=alex.williamson@redhat.com \
--cc=bhelgaas@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).