From nobody Thu Dec 26 01:57:14 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1504716515516422.7912214499378; Wed, 6 Sep 2017 09:48:35 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 20A9521EA35AA; Wed, 6 Sep 2017 09:45:42 -0700 (PDT) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (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 C89BF21E97812 for ; Wed, 6 Sep 2017 09:45:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9E432883A0; Wed, 6 Sep 2017 16:48:30 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-41.rdu2.redhat.com [10.10.120.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3CC2E187BD; Wed, 6 Sep 2017 16:48:29 +0000 (UTC) X-Original-To: edk2-devel@lists.01.org DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9E432883A0 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=lersek@redhat.com From: Laszlo Ersek To: edk2-devel-01 Date: Wed, 6 Sep 2017 18:48:19 +0200 Message-Id: <20170906164819.5082-2-lersek@redhat.com> In-Reply-To: <20170906164819.5082-1-lersek@redhat.com> References: <20170906164819.5082-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 06 Sep 2017 16:48:30 +0000 (UTC) Subject: [edk2] [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: , Cc: Jordan Justen , Brijesh Singh , Thomas Lamprecht , Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Starting with gcc-6, a new warning option called "-Wunused-const-variable" has become available (and enabled by default under our build settings): https://gcc.gnu.org/onlinedocs/gcc-6.4.0/gcc/Warning-Options.html 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 warning to the DEBUG build target. 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 warning for gcc-6+ (in RELEASE builds) as follows: - 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, - 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(). 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(-) diff --git a/OvmfPkg/IoMmuDxe/AmdSevIoMmu.c b/OvmfPkg/IoMmuDxe/AmdSevIoMmu.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_LIST= _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 (ter= nary) +// operator that matches Expression against the EDKII_IOMMU_OPERATION cons= tant +// derived from ShortName. In case of a match, the replacement text evalua= tes +// to an ASCII string literal that stands for the constant. The replacement +// text stops before the colon (":"). The macro invocation site is suppose= d to +// provide the colon and the third operand, either as another invocation o= f 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 ## ShortName)= ) ? \ + (# 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) --=20 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel