From: Laszlo Ersek <lersek@redhat.com>
To: edk2-devel-01 <edk2-devel@lists.01.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>,
Brijesh Singh <brijesh.singh@amd.com>,
Jordan Justen <jordan.l.justen@intel.com>,
Thomas Lamprecht <t.lamprecht@proxmox.com>
Subject: [PATCH 1/1] OvmfPkg/IoMmuDxe: shut up "unused-const-variable" gcc-6 warning in RELEASE
Date: Wed, 6 Sep 2017 18:48:19 +0200 [thread overview]
Message-ID: <20170906164819.5082-2-lersek@redhat.com> (raw)
In-Reply-To: <20170906164819.5082-1-lersek@redhat.com>
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
<https://bugzilla.tianocore.org/show_bug.cgi?id=700>, 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<ShortName>, 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 <ard.biesheuvel@linaro.org>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Thomas Lamprecht <t.lamprecht@proxmox.com>
Reported-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
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 = INITIALIZE_LIST_HEAD_VARIABLE (
#define COMMON_BUFFER_SIG SIGNATURE_64 ('C', 'M', 'N', 'B', 'U', 'F', 'F', 'R')
//
-// ASCII names for EDKII_IOMMU_OPERATION constants, for debug logging.
+// The following macro builds the first two operands of a conditional (ternary)
+// operator that matches Expression against the EDKII_IOMMU_OPERATION constant
+// derived from ShortName. In case of a match, the replacement text evaluates
+// to an ASCII string literal that stands for the constant. The replacement
+// text stops before the colon (":"). The macro invocation site is supposed 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] = {
- "Read",
- "Write",
- "CommonBuffer",
- "Read64",
- "Write64",
- "CommonBuffer64"
-};
+#define BUS_MASTER_OPERATION_NAME(Expression, ShortName) \
+ ((Expression) == (EdkiiIoMmuOperationBusMaster ## ShortName)) ? \
+ (# ShortName)
//
// The following structure enables Map() and Unmap() to perform in-place
@@ -133,9 +133,12 @@ IoMmuMap (
DEBUG_VERBOSE,
"%a: Operation=%a Host=0x%p Bytes=0x%Lx\n",
__FUNCTION__,
- ((Operation >= 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 == NULL) ? 0 : *NumberOfBytes)
--
2.14.1.3.gb7cf6e02401b
next prev parent reply other threads:[~2017-09-06 16:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-06 16:48 [PATCH 0/1] OvmfPkg/IoMmuDxe: shut up "unused-const-variable" gcc-6 warning in RELEASE Laszlo Ersek
2017-09-06 16:48 ` Laszlo Ersek [this message]
2017-09-06 16:56 ` [PATCH 1/1] " Ard Biesheuvel
2017-09-06 17:09 ` Laszlo Ersek
2017-09-06 17:12 ` Ard Biesheuvel
2017-09-06 17:18 ` Laszlo Ersek
2017-09-07 3:38 ` Gao, Liming
2017-09-07 5:47 ` Thomas Lamprecht
2017-09-07 7:32 ` Laszlo Ersek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170906164819.5082-2-lersek@redhat.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox