From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: Re: [PATCH] Avoid clang prior initialization error when listing MTRR flags Date: Mon, 15 Sep 2014 10:51:04 +0100 Message-ID: <5416D2A80200007800034E50@mail.emea.novell.com> References: <1410627472-88435-1-git-send-email-saper@saper.info> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XTSwA-0004U0-7x for xen-devel@lists.xenproject.org; Mon, 15 Sep 2014 09:51:10 +0000 In-Reply-To: <1410627472-88435-1-git-send-email-saper@saper.info> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Marcin Cieslak Cc: xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org >>> On 13.09.14 at 18:57, wrote: > Clang 3.4 complains when compiling range of designated range > initializers: > > gmake[6]: Entering directory `/home/saper/sw/xen/xen/arch/x86/cpu/mtrr' > clang -O1 -fno-omit-frame-pointer -m64 -g -fno-strict-aliasing -std=gnu99 -Wall > -Wstrict-prototypes -Wdeclaration-after-statement > -I/home/saper/sw/xen/xen/include > -I/home/saper/sw/xen/xen/include/asm-x86/mach-generic > -I/home/saper/sw/xen/xen/include/asm-x86/mach-default -msoft-float > -fno-stack-protector -fno-exceptions -Wnested-externs -DHAVE_GAS_VMX > -DHAVE_GAS_EPT -DHAVE_GAS_FSGSBASE -mno-red-zone -mno-sse -fpic > -fno-asynchronous-unwind-tables -DGCC_HAS_VISIBILITY_ATTRIBUTE -fno-builtin > -fno-common -Werror -Wredundant-decls -Wno-pointer-arith -pipe -g -D__XEN__ -include > /home/saper/sw/xen/xen/include/xen/config.h -nostdinc -Wno-parentheses -Wno-format > -Wno-unused-value -Wno-unused-function -Wno-ignored-attributes -DVERBOSE -DHAS_ACPI > -DHAS_GDBSX -DHAS_PASSTHROUGH -DHAS_PCI -DHAS_IOPORTS -fno-omit-frame-pointer > -DCONFIG_FRAME_POINTER -MMD -MF .generic.o.d -c generic.c -o generic.o > generic.c:95:32: error: initializer overrides prior initialization of this > subobject [-Werror,-Winitializer-overrides] > [MTRR_TYPE_UNCACHABLE] = "uncachable", > ^~~~~~~~~~~~ > generic.c:94:32: note: previous initialization is here > [0 ... MTRR_NUM_TYPES - 1] = "?", > ^~~ > generic.c:96:32: error: initializer overrides prior initialization of this > subobject [-Werror,-Winitializer-overrides] > [MTRR_TYPE_WRCOMB] = "write-combining", > ^~~~~~~~~~~~~~~~~ > generic.c:94:32: note: previous initialization is here > [0 ... MTRR_NUM_TYPES - 1] = "?", > ^~~ > generic.c:97:32: error: initializer overrides prior initialization of this > subobject [-Werror,-Winitializer-overrides] > [MTRR_TYPE_WRTHROUGH] = "write-through", > ^~~~~~~~~~~~~~~ > generic.c:94:32: note: previous initialization is here > [0 ... MTRR_NUM_TYPES - 1] = "?", > ^~~ > generic.c:98:32: error: initializer overrides prior initialization of this > subobject [-Werror,-Winitializer-overrides] > [MTRR_TYPE_WRPROT] = "write-protect", > ^~~~~~~~~~~~~~~ > generic.c:94:32: note: previous initialization is here > [0 ... MTRR_NUM_TYPES - 1] = "?", > ^~~ > generic.c:99:32: error: initializer overrides prior initialization of this > subobject [-Werror,-Winitializer-overrides] > [MTRR_TYPE_WRBACK] = "write-back", > ^~~~~~~~~~~~ > generic.c:94:32: note: previous initialization is here > [0 ... MTRR_NUM_TYPES - 1] = "?", > ^~~ > and > > gmake[5]: Entering directory `/home/saper/sw/xen/xen/arch/x86/mm' > clang -O1 -fno-omit-frame-pointer -m64 -g -fno-strict-aliasing -std=gnu99 -Wall > -Wstrict-prototypes -Wdeclaration-after-statement > -I/home/saper/sw/xen/xen/include > -I/home/saper/sw/xen/xen/include/asm-x86/mach-generic > -I/home/saper/sw/xen/xen/include/asm-x86/mach-default -msoft-float > -fno-stack-protector -fno-exceptions -Wnested-externs -DHAVE_GAS_VMX > -DHAVE_GAS_EPT -DHAVE_GAS_FSGSBASE -mno-red-zone -mno-sse -fpic > -fno-asynchronous-unwind-tables -DGCC_HAS_VISIBILITY_ATTRIBUTE -fno-builtin > -fno-common -Werror -Wredundant-decls -Wno-pointer-arith -pipe -g -D__XEN__ -include > /home/saper/sw/xen/xen/include/xen/config.h -nostdinc -Wno-parentheses -Wno-format > -Wno-unused-value -Wno-unused-function -Wno-ignored-attributes -DVERBOSE -DHAS_ACPI > -DHAS_GDBSX -DHAS_PASSTHROUGH -DHAS_PCI -DHAS_IOPORTS -fno-omit-frame-pointer > -DCONFIG_FRAME_POINTER -MMD -MF .p2m-ept.o.d -c p2m-ept.c -o p2m-ept.o > p2m-ept.c:1100:38: error: initializer overrides prior initialization of this > subobject [-Werror,-Winitializer-overrides] > [MTRR_TYPE_UNCACHABLE] = "UC", > ^~~~ > p2m-ept.c:1099:21: note: previous initialization is here > [0 ... 7] = "?", > ^~~ > p2m-ept.c:1101:38: error: initializer overrides prior initialization of this > subobject [-Werror,-Winitializer-overrides] > [MTRR_TYPE_WRCOMB] = "WC", > ^~~~ > p2m-ept.c:1099:21: note: previous initialization is here > [0 ... 7] = "?", > ^~~ > p2m-ept.c:1102:38: error: initializer overrides prior initialization of this > subobject [-Werror,-Winitializer-overrides] > [MTRR_TYPE_WRTHROUGH] = "WT", > ^~~~ > p2m-ept.c:1099:21: note: previous initialization is here > [0 ... 7] = "?", > ^~~ > p2m-ept.c:1103:38: error: initializer overrides prior initialization of this > subobject [-Werror,-Winitializer-overrides] > [MTRR_TYPE_WRPROT] = "WP", > ^~~~ > p2m-ept.c:1099:21: note: previous initialization is here > [0 ... 7] = "?", > ^~~ > p2m-ept.c:1104:38: error: initializer overrides prior initialization of this > subobject [-Werror,-Winitializer-overrides] > [MTRR_TYPE_WRBACK] = "WB", > ^~~~ > p2m-ept.c:1099:21: note: previous initialization is here > [0 ... 7] = "?", > ^~~ > p2m-ept.c:1105:38: error: initializer overrides prior initialization of this > subobject [-Werror,-Winitializer-overrides] > [MTRR_NUM_TYPES] = "??" > ^~~~ > p2m-ept.c:1099:21: note: previous initialization is here > [0 ... 7] = "?", > ^~~ > 6 errors generated. > > Signed-off-by: Marcin Cieslak Apart from the description above being excessive (quoting just one of the error messages would completely suffice), I'm NAKing this because it was intentionally coded the way it is. What I would suggest instead is to enforce -Wno-initializer-overrides. > --- a/xen/arch/x86/cpu/mtrr/generic.c > +++ b/xen/arch/x86/cpu/mtrr/generic.c > @@ -91,9 +91,10 @@ static const char *__init mtrr_attrib_to_str(mtrr_type x) > { > static const char __initconst strings[MTRR_NUM_TYPES][16] = > { > - [0 ... MTRR_NUM_TYPES - 1] = "?", > [MTRR_TYPE_UNCACHABLE] = "uncachable", > [MTRR_TYPE_WRCOMB] = "write-combining", > + [2] = "?", > + [3] = "?", > [MTRR_TYPE_WRTHROUGH] = "write-through", > [MTRR_TYPE_WRPROT] = "write-protect", > [MTRR_TYPE_WRBACK] = "write-back", > diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c > index 15c6e83..50d1529 100644 > --- a/xen/arch/x86/mm/p2m-ept.c > +++ b/xen/arch/x86/mm/p2m-ept.c > @@ -1096,9 +1096,10 @@ static void ept_dump_p2m_table(unsigned char key) > 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", > + [2] = "??", > + [3] = "??", And as a side note - this change is more than just elimination of the compiler warning. Jan