[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH] Avoid clang prior initialization error when listing MTRR flags
>>> On 13.09.14 at 18:57, <saper@xxxxxxxxxx> 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 <saper@xxxxxxxxxx> 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 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |