From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C5FCD21E97804 for ; Wed, 6 Sep 2017 20:35:21 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP; 06 Sep 2017 20:38:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,356,1500966000"; d="scan'208";a="149068039" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga006.fm.intel.com with ESMTP; 06 Sep 2017 20:38:12 -0700 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 6 Sep 2017 20:38:12 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 6 Sep 2017 20:38:11 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.39]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.219]) with mapi id 14.03.0319.002; Thu, 7 Sep 2017 11:38:09 +0800 From: "Gao, Liming" To: Laszlo Ersek , edk2-devel-01 CC: "Justen, Jordan L" , Brijesh Singh , Thomas Lamprecht , "Ard Biesheuvel" Thread-Topic: [edk2] [PATCH 1/1] OvmfPkg/IoMmuDxe: shut up "unused-const-variable" gcc-6 warning in RELEASE Thread-Index: AQHTJzAYXMN3oaqCHEuUryj8jn7D6aKowLFA Date: Thu, 7 Sep 2017 03:38:08 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14D78B39E@shsmsx102.ccr.corp.intel.com> References: <20170906164819.5082-1-lersek@redhat.com> <20170906164819.5082-2-lersek@redhat.com> In-Reply-To: <20170906164819.5082-2-lersek@redhat.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH 1/1] OvmfPkg/IoMmuDxe: shut up "unused-const-variable" gcc-6 warning in RELEASE X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Sep 2017 03:35:22 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Laszlo: I add -Wno-unused-const-variable option in GCC5 RELEASE option, and build= OvmfPkg with GCC5.3. I don't meet any warning or error. Do you meet any is= sue? So, you think we can't add this option in GCC5 tool chain.=20 Thanks Liming > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of La= szlo Ersek > Sent: Thursday, September 7, 2017 12:48 AM > To: edk2-devel-01 > Cc: Justen, Jordan L ; Brijesh Singh ; Thomas Lamprecht > ; Ard Biesheuvel > Subject: [edk2] [PATCH 1/1] OvmfPkg/IoMmuDxe: shut up "unused-const-varia= ble" gcc-6 warning in RELEASE >=20 > Starting with gcc-6, a new warning option called "-Wunused-const-variable= " > has become available (and enabled by default under our build settings): >=20 > https://gcc.gnu.org/onlinedocs/gcc-6.4.0/gcc/Warning-Options.html >=20 > We should give it the same treatment as Ard gave "unused-but-set-variable= " > in commit 20d00edf21d2 ("BaseTools/GCC: set -Wno-unused-but-set-variables > only on RELEASE builds", 2016-03-24); i.e., we should restrict the warnin= g > to the DEBUG build target. >=20 > However, because the new warning is gcc-6+ only, we cannot add > "-Wno-unused-const-variable" to any GCC5 macros in > "BaseTools/Conf/tools_def.template". While the GCC6 toolchain and/or the > desired handling of the new warning are investigated in > , suppress the warn= ing > for gcc-6+ (in RELEASE builds) as follows: >=20 > - Replace the "mBusMasterOperationName" array with the > BUS_MASTER_OPERATION_NAME(Expression, ShortName) macro that compares > Expression against EdkiiIoMmuOperationBusMaster, and in case > of a match, evaluates to "ShortName", stringified, >=20 > - when composing the DEBUG message -- which the preprocessor might > eliminate from RELEASE builds, thereby removing its references to > variables --, build a ladder of comparisons with > BUS_MASTER_OPERATION_NAME(). >=20 > Cc: Ard Biesheuvel > Cc: Brijesh Singh > Cc: Jordan Justen > Cc: Thomas Lamprecht > Reported-by: Thomas Lamprecht > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Laszlo Ersek > --- > OvmfPkg/IoMmuDxe/AmdSevIoMmu.c | 29 +++++++++++--------- > 1 file changed, 16 insertions(+), 13 deletions(-) >=20 > diff --git a/OvmfPkg/IoMmuDxe/AmdSevIoMmu.c b/OvmfPkg/IoMmuDxe/AmdSevIoMm= u.c > index bc57de5b572b..dcd03d8f0474 100644 > --- a/OvmfPkg/IoMmuDxe/AmdSevIoMmu.c > +++ b/OvmfPkg/IoMmuDxe/AmdSevIoMmu.c > @@ -45,17 +45,17 @@ STATIC LIST_ENTRY mRecycledMapInfos =3D INITIALIZE_LI= ST_HEAD_VARIABLE ( > #define COMMON_BUFFER_SIG SIGNATURE_64 ('C', 'M', 'N', 'B', 'U', 'F', 'F= ', 'R') >=20 > // > -// ASCII names for EDKII_IOMMU_OPERATION constants, for debug logging. > +// The following macro builds the first two operands of a conditional (t= ernary) > +// operator that matches Expression against the EDKII_IOMMU_OPERATION co= nstant > +// derived from ShortName. In case of a match, the replacement text eval= uates > +// to an ASCII string literal that stands for the constant. The replacem= ent > +// text stops before the colon (":"). The macro invocation site is suppo= sed to > +// provide the colon and the third operand, either as another invocation= of the > +// same macro, or as a default (fallback) string literal. > // > -STATIC CONST CHAR8 * CONST > -mBusMasterOperationName[EdkiiIoMmuOperationMaximum] =3D { > - "Read", > - "Write", > - "CommonBuffer", > - "Read64", > - "Write64", > - "CommonBuffer64" > -}; > +#define BUS_MASTER_OPERATION_NAME(Expression, ShortName) \ > + ((Expression) =3D=3D (EdkiiIoMmuOperationBusMaster ## ShortNam= e)) ? \ > + (# ShortName) >=20 > // > // The following structure enables Map() and Unmap() to perform in-place > @@ -133,9 +133,12 @@ IoMmuMap ( > DEBUG_VERBOSE, > "%a: Operation=3D%a Host=3D0x%p Bytes=3D0x%Lx\n", > __FUNCTION__, > - ((Operation >=3D 0 && > - Operation < ARRAY_SIZE (mBusMasterOperationName)) ? > - mBusMasterOperationName[Operation] : > + (BUS_MASTER_OPERATION_NAME (Operation, Read) : > + BUS_MASTER_OPERATION_NAME (Operation, Write) : > + BUS_MASTER_OPERATION_NAME (Operation, CommonBuffer) : > + BUS_MASTER_OPERATION_NAME (Operation, Read64) : > + BUS_MASTER_OPERATION_NAME (Operation, Write64) : > + BUS_MASTER_OPERATION_NAME (Operation, CommonBuffer64) : > "Invalid"), > HostAddress, > (UINT64)((NumberOfBytes =3D=3D NULL) ? 0 : *NumberOfBytes) > -- > 2.14.1.3.gb7cf6e02401b >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel