From: Marcin Cieslak <saper@saper.info>
To: xen-devel@lists.xenproject.org
Cc: Marcin Cieslak <saper@saper.info>, JBeulich@suse.com
Subject: [PATCH v2] Avoid clang prior initialization error when listing MTRR flags
Date: Wed, 24 Sep 2014 09:49:33 +0000 [thread overview]
Message-ID: <1411552173-52583-2-git-send-email-saper@saper.info> (raw)
In-Reply-To: <1411552173-52583-1-git-send-email-saper@saper.info>
Clang 3.4 complains when compiling range of designated range
initializers:
generic.c:95:32: error: initializer overrides prior initialization of this subobject [-Werror,-Winitializer-overrides]
[MTRR_TYPE_UNCACHABLE] = "uncachable",
^~~~~~~~~~~~
6 errors generated.
Signed-off-by: Marcin Cieslak <saper@saper.info>
---
xen/arch/x86/cpu/mtrr/generic.c | 20 ++++++++++++--------
xen/arch/x86/mm/p2m-ept.c | 22 ++++++++++++----------
2 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/xen/arch/x86/cpu/mtrr/generic.c b/xen/arch/x86/cpu/mtrr/generic.c
index 493830b..217e1b0 100644
--- a/xen/arch/x86/cpu/mtrr/generic.c
+++ b/xen/arch/x86/cpu/mtrr/generic.c
@@ -89,17 +89,21 @@ boolean_param("mtrr.show", mtrr_show);
static const char *__init mtrr_attrib_to_str(mtrr_type x)
{
- static const char __initconst strings[MTRR_NUM_TYPES][16] =
+ static const char __initconst strings[][16] = {
+ "?", "uncachable", "write-combining",
+ "write-through", "write-protect", "write-back"
+ };
+
+ static const int __initconst strings_map[MTRR_NUM_TYPES] =
{
- [0 ... MTRR_NUM_TYPES - 1] = "?",
- [MTRR_TYPE_UNCACHABLE] = "uncachable",
- [MTRR_TYPE_WRCOMB] = "write-combining",
- [MTRR_TYPE_WRTHROUGH] = "write-through",
- [MTRR_TYPE_WRPROT] = "write-protect",
- [MTRR_TYPE_WRBACK] = "write-back",
+ [MTRR_TYPE_UNCACHABLE] = 1,
+ [MTRR_TYPE_WRCOMB] = 2,
+ [MTRR_TYPE_WRTHROUGH] = 3,
+ [MTRR_TYPE_WRPROT] = 4,
+ [MTRR_TYPE_WRBACK] = 5
};
- return x < MTRR_NUM_TYPES ? strings[x] : "?";
+ return x < MTRR_NUM_TYPES ? strings[strings_map[x]] : "?";
}
static unsigned int __initdata last_fixed_start;
diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c
index 15c6e83..d7efee7 100644
--- a/xen/arch/x86/mm/p2m-ept.c
+++ b/xen/arch/x86/mm/p2m-ept.c
@@ -1095,14 +1095,16 @@ static void ept_dump_p2m_table(unsigned char key)
unsigned long record_counter = 0;
struct p2m_domain *p2m;
struct ept_data *ept;
- static const char memory_types[8][2] = {
- [0 ... 7] = "?",
- [MTRR_TYPE_UNCACHABLE] = "UC",
- [MTRR_TYPE_WRCOMB] = "WC",
- [MTRR_TYPE_WRTHROUGH] = "WT",
- [MTRR_TYPE_WRPROT] = "WP",
- [MTRR_TYPE_WRBACK] = "WB",
- [MTRR_NUM_TYPES] = "??"
+ static const char memory_types[][2] = {
+ "?", "??", "UC", "WC", "WT", "WP", "WB"
+ };
+ static const int memory_types_map[MTRR_NUM_TYPES + 1] = {
+ [MTRR_TYPE_UNCACHABLE] = 2,
+ [MTRR_TYPE_WRCOMB] = 3,
+ [MTRR_TYPE_WRTHROUGH] = 4,
+ [MTRR_TYPE_WRPROT] = 5,
+ [MTRR_TYPE_WRBACK] = 6,
+ [MTRR_NUM_TYPES] = 1
};
for_each_domain(d)
@@ -1143,8 +1145,8 @@ static void ept_dump_p2m_table(unsigned char key)
ept_entry->r ? 'r' : ' ',
ept_entry->w ? 'w' : ' ',
ept_entry->x ? 'x' : ' ',
- memory_types[ept_entry->emt][0],
- memory_types[ept_entry->emt][1]
+ memory_types[memory_types_map[ept_entry->emt]][0],
+ memory_types[memory_types_map[ept_entry->emt]][1]
?: ept_entry->emt + '0',
c ?: ept_entry->ipat ? '!' : ' ');
--
2.0.2
next prev parent reply other threads:[~2014-09-24 9:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-13 16:57 [PATCH] Avoid clang prior initialization error when listing MTRR flags Marcin Cieslak
2014-09-15 9:51 ` Jan Beulich
2014-09-15 10:59 ` Marcin Cieslak
2014-09-15 11:22 ` Jan Beulich
2014-09-24 9:49 ` [PATCH v2] Avoid clang prior initialization error when listing MTRR Marcin Cieslak
2014-09-24 9:49 ` Marcin Cieslak [this message]
2014-09-24 12:17 ` [PATCH v2] Avoid clang prior initialization error when listing MTRR flags Jan Beulich
2014-09-24 12:31 ` Julien Grall
2014-09-24 13:02 ` Marcin Cieslak
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-all 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=1411552173-52583-2-git-send-email-saper@saper.info \
--to=saper@saper.info \
--cc=JBeulich@suse.com \
--cc=xen-devel@lists.xenproject.org \
/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;
as well as URLs for NNTP newsgroup(s).