From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gavin Shan Subject: [PATCH 1/3] drivers/vfio: Rework offsetofend() Date: Mon, 10 Mar 2014 13:46:53 +0800 Message-ID: <1394430415-15574-2-git-send-email-shangw@linux.vnet.ibm.com> References: <1394430415-15574-1-git-send-email-shangw@linux.vnet.ibm.com> Cc: kvm@vger.kernel.org, benh@kernel.crashing.org, aik@ozlabs.ru, Gavin Shan To: alex.williamson@redhat.com Return-path: Received: from e39.co.us.ibm.com ([32.97.110.160]:33062 "EHLO e39.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753186AbaCJFrQ (ORCPT ); Mon, 10 Mar 2014 01:47:16 -0400 Received: from /spool/local by e39.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 9 Mar 2014 23:47:15 -0600 Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id 97E8019D8046 for ; Sun, 9 Mar 2014 23:47:10 -0600 (MDT) Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by b03cxnp08026.gho.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s2A5khsG7340400 for ; Mon, 10 Mar 2014 06:46:43 +0100 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s2A5lCp4010098 for ; Sun, 9 Mar 2014 23:47:12 -0600 In-Reply-To: <1394430415-15574-1-git-send-email-shangw@linux.vnet.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: The macro offsetofend() introduces unnecessary temporary variable "tmp". The patch avoids that and saves a bit memory in stack. Signed-off-by: Gavin Shan --- 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 24579a0..43f6bf4 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.7.10.4