From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id EAD291A1DEB for ; Wed, 26 Oct 2016 15:13:43 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP; 26 Oct 2016 15:13:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,551,1473145200"; d="scan'208";a="184258299" Received: from orsmsx105.amr.corp.intel.com ([10.22.225.132]) by fmsmga004.fm.intel.com with ESMTP; 26 Oct 2016 15:13:44 -0700 Received: from orsmsx113.amr.corp.intel.com ([169.254.9.50]) by ORSMSX105.amr.corp.intel.com ([10.22.225.132]) with mapi id 14.03.0248.002; Wed, 26 Oct 2016 15:13:41 -0700 From: "Kinney, Michael D" To: Laszlo Ersek , edk2-devel-01 , "Kinney, Michael D" CC: "Ni, Ruiyu" , Tim He , "Tian, Feng" , "Dong, Eric" , Cecil Sheng , Ard Biesheuvel , "Justen, Jordan L" , "Gao, Liming" , "Bi, Dandan" , "Wu, Jiaxin" , "Gary Lin" , "Zeng, Star" , Daryl McDaniel , "Carsey, Jaben" , "Fu, Siyuan" , "Fan, Jeff" , "Zhang, Chao B" , "Wei, David" Thread-Topic: [edk2] [PATCH 05/47] MdePkg/Include/Base.h: introduce the ARRAY_SIZE() function-like macro Thread-Index: AQHSL7v1DBtP2bNQtUOr7OKGyveNkaC7TLHA Date: Wed, 26 Oct 2016 22:13:40 +0000 Message-ID: References: <20161026190504.9888-1-lersek@redhat.com> <20161026190504.9888-6-lersek@redhat.com> In-Reply-To: <20161026190504.9888-6-lersek@redhat.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiY2M2ZjA5MGUtNjU3Yy00YWMxLTljMmEtNzk2NDVkYmM0ZjIzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IndEMFhMVGRsM2IxR21tNXYzVVZKMFQxSU9HZEZqdXFRSzZrclwvdXBhQ2tFPSJ9 x-originating-ip: [10.22.254.140] MIME-Version: 1.0 Subject: Re: [PATCH 05/47] MdePkg/Include/Base.h: introduce the ARRAY_SIZE() function-like macro X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Oct 2016 22:13:44 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Laszlo, One comment inline below. Mike > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of La= szlo Ersek > Sent: Wednesday, October 26, 2016 12:04 PM > To: edk2-devel-01 > Cc: Ni, Ruiyu ; Tim He ; Tian, Feng > ; Kinney, Michael D ; Do= ng, Eric > ; Cecil Sheng ; Ard Biesheuvel > ; Justen, Jordan L = ; Gao, Liming > ; Bi, Dandan ; Wu, Jiaxin > ; Gary Lin ; Zeng, Star ; > Daryl McDaniel ; Carsey, Jaben ; > Fu, Siyuan ; Fan, Jeff ; Zhang, = Chao B > ; Wei, David > Subject: [edk2] [PATCH 05/47] MdePkg/Include/Base.h: introduce the ARRAY_= SIZE() > function-like macro >=20 > Several modules use ARRAY_SIZE() already; centralize the definition. (The > module-specific macro definitions are guarded by #ifndef directives at > this point.) >=20 > Cc: Ard Biesheuvel > Cc: Cecil Sheng > Cc: Chao Zhang > Cc: Dandan Bi > Cc: Daryl McDaniel > Cc: David Wei > Cc: Eric Dong > Cc: Feng Tian > Cc: Gary Lin > Cc: Jaben Carsey > Cc: Jeff Fan > Cc: Jiaxin Wu > Cc: Jordan Justen > Cc: Liming Gao > Cc: Michael D Kinney > Cc: Ruiyu Ni > Cc: Siyuan Fu > Cc: Star Zeng > Cc: Tim He > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Laszlo Ersek > --- > MdePkg/Include/Base.h | 13 +++++++++++++ > 1 file changed, 13 insertions(+) >=20 > diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h > index c66614846488..8bdb257e37bd 100644 > --- a/MdePkg/Include/Base.h > +++ b/MdePkg/Include/Base.h > @@ -1211,5 +1211,18 @@ typedef UINTN RETURN_STATUS; > #define RETURN_ADDRESS(L) ((VOID *) 0) > #endif >=20 > +/** > + Return the number of elements in an array. > + > + @param Array An object of array type. Array is only used as an argum= ent to > + the sizeof operator, therefore Array is never evaluated= . The > + caller is responsible for ensuring that Array's type is= not > + incomplete; that is, Array must have known constant siz= e. > + > + @return The number of elements in Array. The result has type UINTN. > + > +**/ > +#define ARRAY_SIZE(Array) (sizeof (Array) / sizeof (Array)[0]) =20 I think adding one extra set of () makes this clearer: #define ARRAY_SIZE(Array) (sizeof (Array) / sizeof ((Array)[0])) > + > #endif >=20 > -- > 2.9.2 >=20 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel