From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gavin Shan Subject: [PATCH 1/3] drivers/vfio: Rework offsetofend() Date: Mon, 3 Mar 2014 11:24:00 +0800 Message-ID: <1393817042-13758-1-git-send-email-shangw@linux.vnet.ibm.com> Cc: alex.williamson@redhat.com, benh@kernel.crashing.org, aik@ozlabs.ru, Gavin Shan To: kvm@vger.kernel.org Return-path: Received: from e7.ny.us.ibm.com ([32.97.182.137]:41811 "EHLO e7.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751759AbaCCDYV (ORCPT ); Sun, 2 Mar 2014 22:24:21 -0500 Received: from /spool/local by e7.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 2 Mar 2014 22:24:20 -0500 Received: from b01cxnp23034.gho.pok.ibm.com (b01cxnp23034.gho.pok.ibm.com [9.57.198.29]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id BCD7CC90042 for ; Sun, 2 Mar 2014 22:24:12 -0500 (EST) Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by b01cxnp23034.gho.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s233OFUa4325854 for ; Mon, 3 Mar 2014 03:24:16 GMT Received: from d01av03.pok.ibm.com (localhost [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s233OEQn010833 for ; Sun, 2 Mar 2014 22:24:15 -0500 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